﻿#ifndef __COMMH_CLASS_H__
#define __COMMH_CLASS_H__

#include "commerrno.h"
#include "CTArray.h"
#include "CTCodeConvert.h"
#include "CTCodeConvert2.h"

using namespace CTLib;

enum enumSystemMaxData
{
    COMM_MOD            = 1000,     //千分位

    EMAX_STRING_KEY_LEN = 100,     //最大的字符串KEY长度，用于数据更新

    MAX_GID_COUNT_PER_USER = 5,             //每个user token最多多少个GID
    ROLENAME_LEN = 49,                      //昵称：6个汉字(UTF8)+@+大区ID（10个数字）
    MIN_ROLENAME_LEN = 4,                   //最少昵称字节数
    MAX_ROLENAME_LEN = 12,                  //最大昵称字节数
    IDENTI_CARD_LEN = 19,                  //用户身份证
    IDENTI_NAME_LEN = 100,                  //用户身份证姓名
    USER_TOKEN_LEN = 100,                   //用户标识长度.
    MAX_ROLE_LEVEL = 300,                   //游戏生命允许的最大用户等级
    OPEN_ROLE_LEVEL = 100,                  //当前开放的最大用户等级
    DATA_RESET_SEC_OF_DAY = 0,              //数据重置时间

    ARENA_RESET_SEC_OF_DAY = 70200,         //竞技场结算时间 19:30(修改该值需注意ARENA_RESET_MIN_SEC_OF_DAY、ARENA_RESET_MAX_SEC_OF_DAY是否为负)
    ARENA_RESET_MIN_SEC_OF_DAY = ARENA_RESET_SEC_OF_DAY - 30,           //最小刷新时间
    ARENA_RESET_MAX_SEC_OF_DAY = ARENA_RESET_SEC_OF_DAY - 5,            //最大刷新时间
    PASSIVE_SKILL_LEVEL_COUNT = 18,         //被动技能等级数量
    TRAINING_CAMP_ROUND_COUNT = 3,          //训练营期数数量
    CLAN_SKILL_COUNT          = 8,          //家族技能
    GLORY_USE_INT_COUNT       = 10,         //成就使用的INT数量，10个INT就表示可以放320个成就
    MAX_USER_PER_ZONE         = 100000,     //单区允许最大用户数（MOD值）, 不要轻易修改这个值，避免影响已有的GID数据，最大注册用户数见MAX_REGISTER_PLAYER
    MAX_ZONE_COUNT            = 10000,      //最大大区数
    MAP_VIEW_COUNT_BECAUSE_CHAT_FRIEND = 3, //因为聊天所以在我的地图视野里的用户最大数
    MAP_VIEW_MAX_USERS_IN_VIEW = 35,        //地图中所能看到的最大用户数
    MAP_VIEW_MAX_CAN_SEE_OTHER_USERS_MAP = 20,   //最大可看见其他用户的地图数
    MIN_MAP_ID_NEED_NOT_SYNC        = 9000000,  //9000000以上的地图不用同步视野

#ifdef _DEBUG
    MAX_REGISTER_PLAYER      = 500,         //最大注册用户数(必须小于MAX_USER_PER_ZONE)
    USER_BASE_INFO_COUNT     = 100,         //用户基本信息数量
    USER_DETAIL_INFO_COUNT   = 50,          //用户详细数据数量
    UNACT_PARTNER_INFO_COUNT = 50,          //未激活伙伴数据数量
    USER_SNS_DETAIL_INFO_COUNT = 50,        //用户SNS详细数据数量
    USER_TOKEN_TO_GID_COUNT  =  MAX_REGISTER_PLAYER,        //USER TOKEN和GID对应表大小
    MAX_PLAYER_ONLINE        = 50,          //最大在线数
    MAP_VIEW_COUNT           = 20,          //地图视野对象数量，表示所有用户同时可能进入的最大地图数量
    MAX_INSTANCE_ZONE_DETAIL_INFO_COUNT = 200, //副本详细信息数
#else
    MAX_REGISTER_PLAYER      = 10000,
    USER_BASE_INFO_COUNT     = 1000,
    USER_DETAIL_INFO_COUNT   = 1000,
    UNACT_PARTNER_INFO_COUNT = 1000,
    USER_SNS_DETAIL_INFO_COUNT = 1000,
    USER_TOKEN_TO_GID_COUNT = MAX_REGISTER_PLAYER,
    MAX_PLAYER_ONLINE         = 800,
    MAP_VIEW_COUNT            = 200,
    MAX_INSTANCE_ZONE_DETAIL_INFO_COUNT = 500,
#endif

    //任务相关
    MAX_TASK_BRANCHS        = 1000,        //分支数量
    MAX_MAIN_TASK_CONFIG    = 10000,       //主线任务配置数
    TASK_CONFIG_ID_MOD      = 10000,       //配置中的ID向任务ID转换时使用，
    //配置ID / TASK_CONFIG_ID_MOD = 分支ID，配置ID % TASK_CONFIG_ID_MOD = 任务ID
    TASK_OPT_CONFIG_ID_MOD = 10000,         //用户操作类任务用来区分操作和操作对象

    CONST_TASK_INSTANCE_ID_MOD = 10000,
    CONST_TASK_ITEM_TYPE_MOD   = 10000,
    MAX_TASK_CONFIG_PER_BRANCH  = 200,      //每分支任务配置数
    MAX_VALID_TASK          = 20,           //最大已领取任务数
    MAX_NEED_TO_ACCEPT      = 20,           //最大需要被接受的任务
    MAX_OPEN_TASK           = 50,           //最大激活任务数
    MAX_WAIT_FOR_OPEN_TASK  = 30,           //最大等待激活任务数
    MAX_TASK_OPEN_COND      = 2,            //最大的激活条件数
    MAX_TASK_FINISH_COND    = 2,            //最大的完成条件数
    MAX_TASK_AWARD       = 4,   //max task award nums
    TASK_AWARD_SETCLASS     = 9999,
    MAX_TASK_FOLLOW         = 20,           //后续待激活任务
    MAX_TRIGGER_PER_TYPE    = 20,           //每种激活类型的最大激活器数量
    MAX_PLAYER_ONLINE_DATA_COUNT = MAX_PLAYER_ONLINE * 2,     //最大在线数据数量
    ITEM_CONFIG_ID_MOD       = 10000,       //物品ID MOD, 除数是ID
    TASK_FIRST_TASK_ID       = 1,           //第一个任务ID
    MAX_REWARD_TASK_LIST_COUNT = 200,       //悬赏任务列表长度
    MAX_REWARD_TASK_CAN_PUBLISH_COUNT = 5,  //悬赏令任务每天可发布数量
    MAX_REWARD_TASK_CAN_ACCEPT_COUNT = 5,   //悬赏令任务每天可接取数量
    MAX_REWARD_TASK_TYPE_COUNT = 4,         //悬赏任务类型数量
    MAX_REWARD_TASK_VALID_SEC = 28800,      //悬赏任务8小时有效
    MAX_REWARD_TASK_PER_ROLE = 10,          //悬赏任务:每人最多可以发10个

    //物品相关
    MAX_ITEM_CONFIG_COUNT    = 10000,       //物品配置数量
    EQUIP_CONFIG_ID_MOD      = 1000000,     //余数是自增值，被除数是配置ID
    MAX_EQUIP_CRYSTAL_NUM    = 3,           //装备可镶嵌的最大魔晶数
    MAX_COMPOSE_CRYSTAL_FRAG_NUM = 6,       //魔晶碎片合成时需要的碎片数
    MAX_CRYSTAL_LEVLE         = 10,         //魔晶的最大等级
    MAX_CRYSTAL_ATTR_TYPE    = 12,          //不同属性类型的魔晶数量
    MAX_ITEM_COUNT_PER_USER = 100,          //最大物品数量，需要大于等于背包格子数+仓库格子数+身上可携带数+其他
    MAX_BAG_GRID_COUNT      = 84,           //背包格子数
    MAX_WAREHOUSE_GRID_COUNT  = 54,         //仓库格子数
    MAX_COMM_GRID_COUNT        = 10,        //保存未被领取的物品
    MAX_DROP_ITEM_PER_TIME     = 30,        //一次掉落物品的最大种类数
    MAX_GROUD_GRID_COUNT   = 10,            //地表背包的格子数
    MAX_DROP_ITEM_TYPE_CONFIG_SET_COUNT = 10000, //掉落物品掉落类型配置最大数量
    MAX_DROP_ITEM_TYPE_CONFIG_PER_SET   = 10,    //掉落物品每掉落类型配置数量
    MAX_DROP_ITEM_RATE         = 1000,           //最大掉落概率
    MAX_SCROLL_CONFIG_COUNT    = 500,            //卷轴配置数量
    MAX_MATERIAL_CONFIG_COUNT  = 2000,           //材料配置数量
    MAX_CRYSTAL_CONFIG_COUNT   = 150,            //魔晶配置数量
    MAX_JEWEL_CONFIG_COUNT     = 20,             //宝石配置数量
    DROP_ITEM_CFG_MAX_ITEM_PER_SUBTYPE = 100,    //每个掉落类型的最大物品数量
    MAX_SCROLL_MATERIAL_NUM     = 5,   //卷轴合成时需要最多的材料数量
    MAX_FRUIT_CONFIG_NUM     = 110,   //果实的最大配置数
    MAX_ITEM_TYPE_DROP_COUNT  = 20,   //物品类型(ITEM_TYPE_DROP1, ITEM_TYPE_DROP2, ITEM_TYPE_DROP3)中的配置数
    MAX_FRUIT_VALIDE_TIME     = 86400 * 7,   //宠物果实的有效时间(7天)
    MAX_ITEM_POS_VALUE        = 1000000,  //不同物品的间的排序权值区间(1百万)
    MAX_ICON_NAME_LEN         = 20,      //图标名的字符串长度
    MAX_LUCKY_DIAL_ITEM_STACK = 99,      //幸运转盘物品堆叠上限

    //魔药相关
    MAX_DRUG_LEVEL     = 8,    //魔药的最高等级
    MAX_DRUG_TYPE      = 4,    //不同的魔药类型
    MAX_DRUG_CONFIG_ID = MAX_DRUG_LEVEL*MAX_DRUG_TYPE, //魔药最大的配置id
    MAX_DRUG_CONFIG_COUNT = 40, //魔药的最大配置
    MAX_DRUG_PURIFY_LEVEL  = 7,  //最高的纯度等级
    MAX_DRUG_SYNTHE_CONFIG_COUNT = 50,    //魔药炼制的最大配置项
    MAX_DRUG_PURIFY_CONFIG_COUNT = 70,  //魔药提纯的最大配置项
    MAX_DRUG_CAPACITY  = 100,       //魔药的最大容量
    MAX_PURIFY_PER_LEVEL   = 100,   //每个纯度等级的最大纯度
    PURIFY_DRUG_PER_NORM_OPER   = 10,   //使用提纯药剂，提纯1次，提升2%纯度
    PURIFY_DRUG_PER_GOLD_OPER   = 30,  //使用金币提纯，提纯1次，提升10%纯度

    //伙伴相关
    MAX_PARTNER_ACT_COUNT  = 9,         //最大同时激活伙伴数
    MAX_PARTNER_CFG_COUNT  = 80,        //最大配置伙伴数量
    MAX_PARTNER_EQUIP_NUM  = 8,         //伙伴身上装备的最多数目
    PARTNER_FAVOR_FOR_LOCK = 1000000,   //当前为信赖度
    PARTNER_FAVOR_FOR_POWER = 2000000,  //当前为锁链能力
    PARTNER_POWER_ADD_FIGHTING = 50,    //若伙伴已锁链 战斗力固定增加特定数值
    MAX_PARTNER_LEVEL = MAX_ROLE_LEVEL, //伙伴等级上限 数值暂时与主角相同 经验数值与主角读同一份配置
    INIT_PARTNER_ID_BORTH = 1,          //初始化角色招募并上阵伙伴ID
    MAX_PARTNER_IN_MATRIX_FLAG = 100000,//重新计算阵位上所有伙伴的在线属性标识

    //装备相关
    MAX_EQUIP_NAME_LEN      = 20,       //装备名称最大长度
    MAX_EQUIP_CONFIG_COUNT  = 500,      //装备配置项最大个数
    MAX_EQUIP_ON_ROLE       = 8,        //每个用户身上的装备数
    //单用户装备最大个数
    //MAX_EQUIP_COUNT_PER_USER = (MAX_PARTNER_ACT_COUNT * MAX_PARTNER_EQUIP_NUM + MAX_BAG_GRID_COUNT + MAX_WAREHOUSE_GRID_COUNT),
    MAX_EQUIP_COUNT_PER_USER = 128,
    DEF_SEND_TIPS_EQUIP_CNT = MAX_EQUIP_COUNT_PER_USER - 8,
    MAX_EQUIP_SUITE_CFG_COUNT = 30,     //套装配置项最大个数
    MAX_ATTR_TYPE_PER_EQUIP  = 7,       //每件装备最多二种不同类型的二级属性+洗练或者祝福属性，最多5个
    MAX_EQUIP_STRENGTH_LEVEL = 150,     //装备最高的强化等级
    MAX_SUITE_ATTR_PER_EQUIP = 3,       //每件装备最多的套装属性
    EQUIP_TRANS_FORM_GOLD    = 100,     //装备转换需要的金币
    MAX_EQUIP_REFINE_LEVEL         = 10,      //最高洗练等级
    MAX_EQUIP_REFINE_ATTR          = 13,      //最多洗练属性类型
    MAX_EQUIP_BLESS_ROLE_COUNT     = 3,       //每次祝福roll属性的最大次数
    MAX_EQUIP_BLESS_LEVEL          = 30,      //最大祝福等级
    MAX_EQUIP_REFINE_ATTR_PER_EQUIP = 5,      //每个装备最多5个洗练属性
    MAX_EQUIP_BLESS_ATTR_PER_EQUIP = 4,       //每个装备最多4个祝福属性
    MAX_EQUIP_BLESS_POINT_PER_ATTR = 10,      //每个属性对应的祝福点数量

    //商店相关
    MAX_USER_SHOP_ITEM_NUM = 10,        //商品代售物品数
    MAX_USER_SHOP_GRID_NUM = 36,        //商品对话框格子数目
    MAX_SHOP_BUY_BACK_ITEM_COUNT = 36,  //回购列表大小
    MAX_MYSTICAL_SHOP_GRID_NUM = 6,     //神秘商店的格子数
    MAX_MYSTICAL_SHOP_HISTORY_NUM = 10, //神秘商店显示的最近购买记录
    MAX_CLAN_SHOP_ITEM = 20,            //家族商店最多的物品数
    MAX_CRYSTAL_SHOP_COUNT = 30,        //宝石商店最多的物品数
    MAX_CRYSTAL_SHOP_TIME  = 7200,      //宝石商店物品更新时间

    //副本相关
    MAX_INSTANCE_BRANCH_COUNT     = 200,             //非主线副本数量
    MAX_INSTANCE_MAIN_CONFIG_COUNT = 10000,         //主线副本配置数量
    MAX_INSTANCE_CHALLENGE_CONFIG_COUNT = 10000,    //挑战副本配置数量
    MAX_INSTANCE_BRANCH_CONFIG_COUNT = 200,         //分支副本配置数量
    MAX_INSTANCE_CONFIG_COUNT = MAX_INSTANCE_MAIN_CONFIG_COUNT + MAX_INSTANCE_CHALLENGE_CONFIG_COUNT + MAX_INSTANCE_BRANCH_CONFIG_COUNT * MAX_INSTANCE_BRANCH_COUNT,
    DROP_ITEM_CFG_SUBTYPE_STR_LEN = 50,            //掉落物品配置中掉落字类型的字符串配置长度
    DROP_ITEM_CFG_DROP_ITEM_COUNT_PER_GROUP = 6,   //每类掉落物品的最大掉落种类
    MAX_INSTANCE_FIRST_ACCOMPLISH_BONUS_COUNT = 6, //每个首次通关奖励配置的物品数
    MAX_INSTANCE_FIRST_ACCOMPLISH_BONUS_CFG_COUNT = 100000, //首次通关奖励配置
    INSTANCE_RESET_ELITE_COST_GOLD = 200,           //精英副本重置价格
    MAX_INSTANCE_ELITE_CONFIG_COUNT = 20,           //精英副本配置项最大数量
    MAX_INSTANCE_SECRET_CONFIG_COUNT = 20,          //秘境副本配置项最大数量
    MAX_INSTANCE_MUSEUM_RANK_LEN = 5,               //博物馆副本排行榜长度
    INSTANCE_RESET_SECRET_COST_GOLD = 150,          //重置秘境的价格
    INSTANCE_MUSEUM_FREE_RESET_COUNT = 1,           //博物馆免费重置次数
    MAX_INSTANCE_BATTLE_SCORE_COUNT = 100,          //战斗评分配置
    MAX_GRADE_BONUS_COUNT_PER_MAP   = 3,            //每个地图的星级评分奖励数量
    MAX_GRADE_BONUS_COUNT           = 30,           //副本评分奖励最大个数
    MAX_INSTANCE_COUNT_PER_GRADE_BONUS = 100,       //一个地图所对应的副本数量
    MAX_CAN_RESET_SECRET_COUNT = 2,                 //秘境最大可重置数量

    //怪物相关
    MAX_MONSTER_TYPE_CONFIG_COUNT      = 10000,   //最大怪物类型配置数量
    MAX_MONSTER_ATTR_CONFIG_COUNT      = 200,     //最大怪物属性配置数量
    MAX_MONSTER_CONFIG_COUNT           = 50000,   //最大怪物配置数量
    MAX_MONSTER_MEMBER_PER_GROUP       = 5,       //每堆怪物中的怪物最大数量
    MAX_MONSTER_GROUP_CONFIG_COUNT     = 10000,   //怪物队伍的最大配置数量
    MAX_MONSTER_GROUP_PER_INSTANCE     = 5,       //一个副本最多有几堆怪物
    MAX_MONSTER_KILL_BONUS_CONFIG_COUNT = 200,    //击杀怪物队伍奖励配置数
    MAX_MONSTER_FIRST_KILL_BONUS_CONFIG_COUNT = 200, //首次击杀怪物队伍奖励配置数

    //战斗相关
    MAX_BATTLE_ACTION_COUNT = 10,               //最大行动数量，系统限制
    MAX_BATTLE_GRIDS_PER_SIDE = 9,              //单边最大格子数，也是布阵的边界
    MAX_BATTLE_GRIDS = MAX_BATTLE_GRIDS_PER_SIDE * 2,
    MAX_BATTLE_ROLES_PER_SIDE = 5,             //单边最大的人数
    MAX_BATTLE_ROLES = MAX_BATTLE_ROLES_PER_SIDE * 2,
    MAX_BATTLE_PVP_ROLES_COUNT = 2,             //根据MAX_BATTLE_ROLES_PER_SIDE定制超出此值不加载伙伴
    MAX_EFFECT_PER_SKILL = 5,                   //每个技能的最多效果数量
    MAX_AFFECT_PER_SKILL = 2,                   //最大技能生效次数
    MAX_SKILL_PER_ROLE = 3,                     //每个角色的最大技能数
    MAX_NORMAL_ATK_BEFORE_ACAD = 2,             //2次普通攻击1次学院技能
    MAX_SKILL_TARGET_COUNT = 10,                //技能最大目标数
    MAX_BATTLE_DATA_PRECISION = 1000,           //战斗计算精度
    BATTLE_FALLBACK_DISTANCE = 6,               //撤退距离
    MAX_VIDEO_FRAME_COUNT = 20,                 //单条战斗录像参数个数
    MAX_VIDEO_ACTION_COUNT = 5000,              //单场战斗总的战斗录像命令
    MAX_ROLE_ANGER = 100,                       //默认怒气上限
    MAX_ROLE_ANGER_ADD = 200,                   //角色累加怒气上限
    MAX_ROLE_COURAGE = 100,                     //角色勇气上限
    MAX_BATTLE_CIRCLE_COUNT = 100,              //战斗回合数上限
    MAX_BATTLE_VIDEO_COUNT = 25,                //传输给前端的战斗录像回合上限
    MAX_VIDEO_KEY_LEN = 60,                     //录像文件名程度
    MAX_BATTLE_BUFF_COUNT = 10,                 //战斗个体Buff数量
    MAX_BATTLE_BUFF_LAST_COUNT = 20,            //战斗中Buff叠加层数上限
    MAX_BATTLE_REVISE_ATTACK = 20,              //战斗中修正战斗伤害上限
    MAX_BATTLE_ROLE_SKILL_COUNT = 10,           //战斗中角色预执行技能上限
    MAX_BATTLE_NAME_BUFF = 10240,               //GM name消息长度
    MAX_BATTLE_OBJ_NAME_LEN = ROLENAME_LEN + 15,               //战斗个体昵称 有可能是组合名称 比如学院BOSS

    //技能相关
    MAX_SKILL_EFF_CFG_COUNT = 1500,              //技能效果配置数量
    MAX_SKILL_AFF_CFG_COUNT = 2000,              //技能功能配置数量
    MAX_SKILL_CONFIG_COUNT = 1000,              //技能配置数量

    ATTR_ROLE_DEFAULT_FIGHT_BACK        = 750,      //角色默认反击率
    ATTR_PARTNER_DEFAULT_FIGHT_BACK     = 750,      //伙伴默认反击率

    //阵形相关
    MAX_MATRIX_LIST_COUNT = 1,              //角色身上保存的阵形数量
    MAX_MATRIX_UNIT_COUNT = 5,              //每个阵形保存的个体数量
    MAX_MATRIX_POS        = 6,              //阵位数

    //卡片
    MAX_CARD_DIVINE_POS_CONIFG = 6,         //占卜牌配置数量
    MAX_CARD_DIVINE_POS_DROP_TYPE_COUNT = 3, //每个占卜牌可能掉落的类型数
    MAX_CARD_GOLD_DIVINE_POS_DROP_TYPE_COUNT = 5, //金币占卜可能掉落的类型数
    MAX_CARD_LEVEL             = 30,        //卡片最高等级
    MAX_CARD_CONFIG_COUNT_PER_TYPE  = 30,   //每个种类的卡片配置数
    MAX_CARD_CONFIG_COUNT      = 200,       //卡片配置数量
    MAX_VORTEX_CONFIG_COUNT    = 30,
    MAX_CARD_DIVINE_CARD_COUNT = 60,        //占卜界面每推卡片的最大数量
    MAX_CARD_BUG_GRID_COUNT    = 25,        //卡片背包大小
    MAX_CARD_COUNT             = 120,       //所能拥有的卡片总量，包括装备的
    MAX_CARD_COUNT_PER_ROLE    = 8,         //每个人所能装备的卡片数
    MAX_CARD_GOLD_DIVINE_CARD_COUNT = 5,    //金币占卜最大可容纳的卡片数
    MAX_CARD_GOLD_DIVINE_NEED_GOLD = 100,   //金币占卜金币消耗
    CARD_GOLD_DIVINE_USE_MATERIAL = 188,    //魔源水晶, 金币占卜用

    //魂器
    MAX_SOUL_MAX_BALL_LEVEL = 3,   //封印球最大升3级
    MAX_SOUL_MAX_BALL_COUNT = 6,   //6种封印球
    MAX_SOUL_STAT_LEVEL = 10,      //魂器最大等级

    //花园
    MAX_GARDEN_LAND     = 8,        //土地数量
    GARDEN_MAX_LAND_LEVEL = 3,      //土地最大等级

    MAX_GARDEN_GOBLIN_COUNT = 8,    //地精数量, 必须小于GARDEN_MAX_FRIEND_LIST
    MAX_GARDEN_DROP_HOE_ON_LAND = 5, //每天花园中的地精被驱赶完毕后后，留给有求必应屋主人的奖励挖宝锄

    MAX_GARDEN_HOE_COUNT = 16,      //挖宝锄最大数量
    GARDEN_MAX_HOE_ON_LAND = 8,     //未收取的挖宝锄数量
    GARDEN_ADD_SECEND_PER_GOBLIN = 3600, //每个地精增加60分钟
    GARDEN_GOBLIN_DISAPPEAR_TIME = 57600, //地精消失时间  16小时
    GARDEN_PICK_TIME            = 28800,    //8小时后可摘
    GARDEN_MAX_BUY_HOE_IN_SHOP = 50,    //每天可在花园商店购买挖宝锄的最大次数
    GARDEN_BUY_HOE_PER_TIME    = 1,     //一次购买的数量
    GARDEN_MAX_BUY_SEED_IN_SHOP = 50,    //每天可在花园商店购买种子的最大次数
    GARDEN_BUY_SEED_PER_TIME = 20,       //一次购买的数量
    GARDEN_MAX_FLOWER_COUNT = 5,          //花卉种类数
    GARDEN_MAX_SLEEP_SEC_PER_DAY = 30600, //每天必须睡眠8.5小时
    GARDEN_MAX_ACORNS_MAX_GET_BONUS_COUNT = 8, //8次以上次数没奖励
    GARDEN_MAX_ACORNS_COUNT = 16,          //橡果数量，必须小于GARDEN_MAX_FRIEND_LIST
    GARDEN_MAX_FRIEND_LIST  = 20,         //最大记录的好友列表
    GARDEN_CATCH_GOBLIN_BONUS_SEED_RATE = 500, //驱赶地精奖励种子的概率
    GARDEN_CATCH_GOBLIN_BONUS_SEED_COUNT = 1 , //驱赶地精奖励种子的数量
    GARDEN_SEED_ITEM_ID                 = 189, //精灵星尘物品ID
    GARDEN_LEAF_ITEM_ID                 = 190, //世界树之叶物品ID
    GARDEN_NOTE_ITEM_ID                 = 191, //探险笔记物品ID
    GARDEN_MAX_CAN_SPEED_COUNT          = 10,   //最多可加速的次数
    GARDEN_MAX_CAN_DIG_BOX_COUNT        = 50,  //最多可挖宝的次数
    GARDEN_MAX_SPEED_PRICE              = 30,   //家族成长的价格

#ifdef _DEBUG
    GARDEN_FLUSH_GOBLIN_TIME  = 240,
    GARDEN_NEW_SLEEP_VALID_TIME = 86400,
#else
    GARDEN_FLUSH_GOBLIN_TIME  = 3600,    //60分钟内随机刷出地精
    GARDEN_NEW_SLEEP_VALID_TIME = 86400 * 3, //休眠事件3天后生效
#endif // _DEBUG

    //好友系统
    FRIEND_OPEN_LEVEL    = 8,           // 开放等级
    FRIEND_MAX_FRIEND_COUNT = 100,          //好友最大数量
    FRIEND_MAX_BLACK_COUNT = 20,            //黑名单
    FRIEND_MAX_RECENT_COUNT = 10,           //最近联系
    FRIEND_MAX_ENEMY_COUNT = 10,            //敌视列表
    FRIEND_MAX_TREE_CONFIG_COUNT = 6,      //好友经验树配置数量
    FRIEND_MAX_TREE_CAN_USE_LEVEL = 44,      //最大可使用经验树的等级
    FRIEND_MAX_TREE_CAN_SEND_BLESS_COUNT = 20,    //每天可发送的祝福次数
    FRIEND_MAX_TREE_CAN_SEND_INVITE_COUNT = 5,          //每天可发送的邀请次数
    FRIEND_MAX_TREE_FRUIT_EXP   = 5000,          //每个果实的经验
    FRIEND_MAX_TREE_BLESS_SILVER = 1000,       //祝福的银币奖励

    FRIEND_QQ_INVITE_PAY_ANY_COUNT = 2,       //邀请QQ好友消费任意Q点人数

    //竞技场
    ARENA_MIN_LEVEL                 = 15,   //参与竞技场的最小等级
    ARENA_MAX_Rank_HISTORY_COUNT = 10,   //
    ARENA_MAX_VIDEO_COUNT           = 5,
    ARENA_MAX_HERO_LIST_COUNT       = 20,   //英雄榜角色数量
    ARENA_MAX_HERO_GID_COUNT        = 3,    //英雄榜角色GID数量
    ARENA_MAX_SEG_CONFIG_COUNT      = 15,   //最大的等级段数量
    ARENA_MAX_BONUS_RANK_CONFIG      = 501,   //最大的排名奖励差异配置数量
    ARENA_MAX_FIGHT_COUNT_PER_DAY   = 15,   //每天可挑战的次数
    ARENA_MAX_TOP_INFO_COUNT        = 3,    //置顶信息数量
    ARENA_MAX_OPP_COUNT             = 10,   //展示的对手数量
    ARENA_MAX_FIGHT_LOSS_COOL_SEC = 60 * 10,
    ARENA_MAX_WIN_SAY_LEN_BYTE      = 50 * 2,
    ARENA_MAX_WIN_SAY_LEN           = 50 * 3, //胜利宣言长度
    ARENA_BATTLE_COUNT_GOLD_PRICE   = 2,      //玩家可以同金币购买可竞技次数。初始价格为2金币，其后每次递增2金币，直至50金币封顶。
    ARENA_BATTLE_COUNT_MAX_GOLD_PRICE = 50,
    ARENA_FLUSH_BATTLE_TIME_GOLD_PRICE   = 2,      //当竞技挑战失败时，进入10分钟冷却时间。冷却时间可通过金币消除。算法同一般消除冷却时间算法
    ARENA_FLUSH_BATTLE_TIME_MAX_GOLD_PRICE = 50,

    //状态相关
    MAX_STATUS_SKILL_COUNT = 3,             //每个状态包含的技能数量
    MAX_STATUS_SKILL_AFF_COUNT = 3,         //每个状态包含的备选技能功能数量
    MAX_STATUS_GROUP_COUNT = 10,            //每个状态组包含的状态数量
    MAX_STATUS_CONFIG_COUNT = 1500,         //状态配置表条目总数量
    MAX_STATUS_GROUP_CFG_COUNT = 300,       //状态组配置表条目总数量
    MAX_STATUS_PLAYER_COUNT = 32,           //角色身上总的状态数量
    MAX_STATUS_UPDATE_TIME_GAP = 13,        //角色移动时候更新状态列表时间间隔

    //秘宝相关
    MAX_TREASURE_CFG_COUNT  = 10,           //最大配置秘宝数量
    MAX_TREASURE_ACT_COUNT  = 10,           //最大激活秘宝数量
    MAX_TREASURE_OBJ_COUNT  = 2,            //最大装配秘宝数量
    MAX_TREASURE_UP_LEVEL  = 31,            //秘宝等级上限(不可达到)[秘宝初始等级0 最大等级30 跨度为31]
    MAX_TREASURE_POS_TWO_LIMIT  = 60,       //第二装配位等级需求
    TREASURE_ANGER_COST_UNIT = 20,          //秘宝(隆基努斯长矛)怒气消耗单元
    TREASURE_LEVEL_ADD_FIGHTING = 40,       //秘宝每个等级增加的战斗力

    //最多未打开的礼包数
    MAX_LOCKED_GIFT_COUNT  = 10,

    //场景相关 这里的场景满足视野同步和怪物配置
    MAX_SCENE_CONFIG_COUNT = 100,          //场景配置表条目总数量

    //世界BOSS相关
    MAX_WORLD_BOSS_ATK_CFG_COUNT = 10,  //世界BOSS伤害比例表条目总数量
    MAX_WORLD_BOSS_GIFT_COUNT = 10,     //世界BOSS排名榜奖励礼包数量

    //学院BOSS相关
    MAX_ACADEMY_BOSS_GIFT_COUNT = 10,   //学院BOSS排名榜奖励礼包数量

    //活动相关
    MAX_ACT_SEGMENT_COUNT = 3,          //每个活动包含的时间段数量
    MAX_ACT_CONFIG_COUNT = 200,         //活动配置表条目总数量
    MAX_ACT_STATUS_CFG_COUNT = 20,      //活动状态配置表条目总数量
    MAX_ACT_TIMER_COUNT = 200,          //活动类定时器总数量

    MAX_SYSTEM_NOTICE_SEGMENT_COUNT = 5,    //每个系统提示包含的时间段数量
    MAX_SYSTEM_NOTICE_CONFIG_COUNT = 100,   //系统提示配置表条目总数量

    //家族
    MIN_CLAN_NAME_LEN = MIN_ROLENAME_LEN,              //家族名称最少字节数
    MAX_CLAN_NAME_LEN = MAX_ROLENAME_LEN,              //家族名称最多字节数
    CLAN_NAME_STRING_SIZE     =  ROLENAME_LEN,         // 名称6个汉字(UTF8)+@+大区ID（10个数字）
    MAX_CLAN_COUNT_PER_ZONE   =  400,     //单区支持的家族数
    MAX_CLAN_ID_RANGE         =  10000,   //单区可使用的家族ID范围
    CREATE_CLAN_NEED_GOLD = 50,
    CLAN_VICE_LEADER_NUM  =  2,         //副族长数
    CLAN_ELITE_NUM        =  5,         //精英数
    CLAN_NORM_MEMBER_NUM  =  33,
    //每个家族最多的成员数.(包含族长,副族长,精英,普通成员)
    MAX_CLAN_MEMBER_COUNT =  (CLAN_VICE_LEADER_NUM + CLAN_ELITE_NUM + CLAN_NORM_MEMBER_NUM),
    MAX_CLAN_JOIN_REQ_NUM  = 50,      //申请加入请求数
    MAX_CLAN_NOTICE_STRING_LEN = 256,   //公告牌字符串最大长度(最长80个汉字)
    MAX_CLAN_LOG_NUM  = 40,             //家族日志数
    MAX_JOIN_CLAN_REQ_PER_USER = 3,     //每个用户可申请的家族数
    MAX_CLAN_SKILL_NUM = 17,            //每个用户的家族技能数
    MAX_CLAN_LEVEL = 150,                //家族的最高等级
    MAX_CLAN_RECOMMD_TIME = (2*86400),   //自荐时,族长不在线的时间(48小时)
    MAX_CLAN_DELAY_DELETE_LEVEL = 3,  //家族延迟解散的等级
    MAX_CLAN_DELAY_DELETE_DAY = 3,  //家族延迟的天数
    MAX_CLAN_DELAY_DELETE_TIME = 82800,  //家族延迟的时间 (23点解散)
    MAX_CLAN_TODAY_CONTRI_TIME = 86400,  //清空今日贡献度时间 (24点结算)
    MAX_CLAN_SHOP_REFRESH_TIME = DATA_RESET_SEC_OF_DAY,  //家族商店刷新的时间
    MAX_CLAN_SORT_TIME   = 1800,   //家族排序时间间隔 (半个小时)
    MAX_CLAN_STORAGE_COUNT  = 32,  //家族仓库大小
    MAX_CLAN_BONUS_COUNT  = 4,     //单次最多可分配的家族奖励数
    MAX_CLAN_PENDING_BONUS = 10,    //个人最多未领取的家族奖励数
    MAX_CLAN_BONUS_MEMBER  = 20,    //单次最多可分配的家族奖励成员数
    MAX_CLAN_SKILL_LEVEL   = 150,   //家族技能的最高等级
    CLAN_AUCTION_SILVER_ADDITION = 50,  //提高千分之50的增益
    MAX_CLAN_TREE_LEVEL = 30,   //神树最高等级
    MAX_CLAN_TREE_TYPE = 4,     //神树最多类型树
    MAX_CALC_FRUIT_DAY = 0,     //计算摘果次数的星期数.(0为星期天, 星期六)
    MAX_CLEAR_TREE_TIME = 86400,     //神树摘果次数结算时间, 重置购买浇水次数时间. (24点)
    MAX_FREE_WATER_TIMES = 3,    //免费浇水次数
    MAX_TREE_RANK_SIZE  = MAX_CLAN_MEMBER_COUNT,    //累计成长排行榜大小
    MAX_SAMALL_FRUIT_CNT = 7,    //小果实的最大数
    MAX_BIG_FRUIT_CNT = 7,       //大果实的最大数
    CLAN_TREE_TOTAL_LEVEL = MAX_CLAN_TREE_LEVEL * MAX_CLAN_TREE_TYPE, // 神树总等级
    MAX_RECURIT_FREE_CNT = 3,   //每日免费招募次数
    DEF_CLAN_RECURIT_GOLD = 5,  //发布一次花费5符石

    //上课系统
    MAX_LESSON_COUNT = 10,              //最大课程数
    MAX_LESSON_COUNT_CAN_TAKE_PER_DAY = 5,  //每天最多可上课的次数
    MAX_DEFAULT_REQUIRED_LESSON_COUNT = 2,  //缺省必修课数量
    MAX_DEFAULT_ELECTIVE_LESSON_COUNT = 2,  //缺省选修课数量
    MAX_BUY_REQUIRED_LESSON_COUNT = 1,          //最大可购买必修课数量
    MAX_BUY_ELECTIVE_LESSON_COUNT = 1,          //最大可购买选修课数量
    MAX_LESSON_LEVEL          = 30,         //最大课程等级
    SELECT_LESSON_COST_GOLD = 50,           //指定课程消耗的金币数
    LESSON_COUNT_COST_GOLD = 20,           //购买上课次数的价格
    LESSON_COOL_SECS = 10 * 60,             //上课冷却时间
    LESSON_TASK_BRANCH_ID = 999,              //上课任务分支ID

    //聊天系统
    MAX_CHAT_MSG_LEN = 120,                   //最大聊天字符长度
    MAX_CHAT_SPEED   = 2,                     //2秒一条
    MAX_CHAT_MSG_CHECK_LEN = 30,              //检查30字节
    MAX_CHAT_MSG_COUNT = 100,                 //累计保存100条
    MAX_CHAT_RATE = 333,                      //20%的概率检查

    //版署账号,数量100
    MAX_SPECIAL_ACCOUNT = 1000,

    //炼金
    ALCHEMY_MIN_LEVEL = 15,  //进行炼金需要的最低等级

    //精力
    MAX_ENERGY_GROW_COUNT = 200,  //精力自然增长上限
    MAX_ENERGY_COUNT = 1000,       //精力上限
    MAX_ENERGY_NORMAL_MEAL_COUNT = 5, //普通餐菜品数量
    MAX_ENERGY_NORMAL_NOW_CAN_EAT_COUNT = 3,  //当前可吃饭的数量
    MAX_ENERGY_MAGIC_MEAL_COUNT = 4,  //魔法锅菜品数量
    MAX_ENERGY_GROW_INTERVAL = 1800,  //精力每半小时涨一次
    MAX_ENERGY_GROW_COUNT_PER_INTERVAL = 5,  //精力每次增长5点
    MAX_MEAL_DROP_TYPE = 10,        //菜品掉落最大类型
    MAX_MEAL_COUNT_PER_DROP = 10,   //每个菜品的详细掉落类型
    MAX_MEAL_DROP_CONFIG_COUNT = 10,    //菜的配置类型
    MAX_MEAL_DETAIL_DROP_CONFIG_COUNT = 20, //菜的详细配置类型
    MAX_MEAL_MAGIC_MEAL_ID = 1,             //魔力锅ID
    MAX_ENERGY_BUY_ADD_COUNT = 40,          //每次购买增加的精力数

    ENERGY_FIRST_MEAL_BEGIN_HOUR = 12,      //第一餐开始小时数，12点
    ENERGY_SECOND_MEAL_BEGIN_HOUR = 18,     //第二餐开始小时数，18点

    //魔晶开采
    MAX_MINE_DROP_COUNT = 15,      //开采最多掉落的物品类型
    DEEP_MINE_NEED_GOLD_CNT      = 50,  //深层魔晶消耗的金币数
    CORE_MINE_NEED_SOLVENT_CNT   = 5, //核心魔晶消耗的溶剂数
    MAX_BATCH_MINE_COUNT = 10,  //批量开采的最大次数
    MINE_CRYSTAL_CLEAR_TIME = 86400, //每天24点, 更新开采次数的时间点(24*3600)

    //日常任务配置---------------Begin---------------
    DAILY_TASK_CLASSTYPE_NONE           = 0, //空类型
    DAILY_TASK_CLASSTYPE_PRESTIGE       = 1, //声望类型
    DAILY_TASK_CLASSTYPE_LEVEL          = 2, //升级类型
    DAILY_TASK_CLASSTYPE_MONEY          = 3, //赚钱类型
    DAILY_TASK_CLASSTYPE_STRONG         = 4, //变强类型
    DAILY_TASK_FIND_YES_TASK_NEED_GOLD  = 10, //找回任务所需要的金币

    //小秘书类型
    SECRETARY_TYPE_COMMON               = 1, //普通小秘书
    SECRETARY_TYPE_PRESTIGE             = 2, //声望小秘书
    SECRETARY_TYPE_SILVER               = 3, //银币小秘书
    SECRETARY_LIVE_TIME                 = 2592000, //小秘书有效期30天

    DAILY_TASK_ID_1 = 1  ,  //炼金
    DAILY_TASK_ID_2 = 11 ,  //宠物探险
    DAILY_TASK_ID_3 = 21 ,  //魔法修炼(种花)
    DAILY_TASK_ID_4 = 31 ,  //精灵星尘购买
    DAILY_TASK_ID_5 = 41 ,  //宝物探险
    DAILY_TASK_ID_6 = 51 ,  //宝物探险购买
    DAILY_TASK_ID_7 = 61 ,  //驱赶捣蛋鬼
    DAILY_TASK_ID_8 = 71 ,  //购买精力
    DAILY_TASK_ID_9 = 81 ,  //享用午餐
    DAILY_TASK_ID_10  = 91 ,  //享用晚餐
    DAILY_TASK_ID_11  = 101,  //扫荡博物馆
    DAILY_TASK_ID_12  = 111,  //卡片占卜
    DAILY_TASK_ID_13  = 121,  //上课
    DAILY_TASK_ID_14 = 131,  //上课任务
    DAILY_TASK_ID_15 = 141,  //浅层开采魔晶
    DAILY_TASK_ID_16 = 151,  //深层开采魔晶
    DAILY_TASK_ID_17 = 161,  //悬赏令任务
    DAILY_TASK_ID_18 = 171,  //家族转盘
    DAILY_TASK_ID_19 = 181,  //家族充能
    DAILY_TASK_ID_20 = 191,  //家族战
    DAILY_TASK_ID_21 = 201,  //幸运闯关
    DAILY_TASK_ID_22 = 211,  //世界BOSS
    DAILY_TASK_ID_23 = 221,  //学院试炼BOSS
    DAILY_TASK_ID_24 = 231,  //竞技场
    DAILY_TASK_ID_25 = 241,  //梦魇远征
    DAILY_TASK_ID_26 = 251,  //挑战秘境BOSS
    DAILY_TASK_ID_27 = 261,  //领地战
    DAILY_TASK_ID_28 = 271,  //怪物攻城
    DAILY_TASK_ID_29 = 281,  //刷神秘商店
    DAILY_TASK_ID_30 = 291,  //家族捐献
    DAILY_TASK_ID_31 = 300,  //一战到底

    MAX_DAILY_VIP_DEST_CONFIG = 15, //vip目标次数配置，目前每个任务对应vip级别数12
    MAX_DAILY_TASK_CONFIG = 50, //日常任务数量
    MAX_DAILY_TASK_CLASS_CONFIG = 5, //任务类型数量
    MAX_TBOX_NUM = 20,              //宝箱数量
    MAX_TBOX_AWARD_NUM = 4,          //单个宝箱的奖励数量
    CONST_VIP_HIGH_LEVEL0 = 0,      //not vip common user
    CONST_VIP_HIGH_LEVEL1 = 3,      //vip1-3
    CONST_VIP_HIGH_LEVEL2 = 6,      //vip4-6
    CONST_VIP_HIGH_LEVEL3 = 9,      //vip7-9
    CONST_VIP_HIGH_LEVEL4 = 10,      //vip10+
    MAX_SECRETARY_STYLE_NUM = 3,    //小秘书形象最大数量
    MAX_SECRETARY_LEVEL     = 100,  //小秘书最大等级

    CONST_DIY_DOUBLE_AWARD_LEVEL = 20, //开启宝箱需要的等级
    CONST_TASK_CLASS_STATUS = 1000, //开启类型任务的宝箱奖励基值
    CONST_DOUBLE_AWARD_BASE = 10,   //试试手运双倍奖励的状态基值
    CONST_ADD_INTIMACY      = 5,    //每次开启宝箱增加亲密度
    CONST_TBOX_CANOT_OPEN = 0,      //宝箱不可开启
    CONST_TBOX_CAN_OPEN = 1,      //宝箱可开启
    CONST_TBOX_OPENED = 2,      //宝箱已经开启
    //日常任务配置---------------End---------------

    //宠物相关----------------------start--------------
    //宠物形态配置
    PET_STATUS_TYPE_OWL                 = 1, //猫头鹰
    PET_STATUS_TYPE_CAT                 = 2, //猫
    PET_STATUS_TYPE_HAMSTER             = 3, //仓鼠
    PET_STATUS_TYPE_DOG                 = 4, //狗

    PETNAME_LEN                         = 64,//宠物昵称最大长度
    MAX_EXPLORE_CONFIG_NUM = 100,              //探险最大配置数量
    MAX_EXPLORE_AWARD_NUM = 4,      //单次探险的奖励数量
    MAX_PET_LEVEL_CONFIG = 10,      //每等阶星级数,每等阶最多10星级,最多10个等阶
    MAX_PET_STAR         = 10,        //星级从0开始，最大值9,共10个星级
    MAX_PET_STAR_CONFIG = 110,      //等阶数*每等阶星级数
    MAX_PET_EXPLORE_NUM = 10,       //最大探险数量

    MAX_PET_EXPLORE_DAILY_NUM = 10, //用户每天最多探险次数
    MAX_RATE_VALUE = 1000,          //概率最大分母值
    MAX_DAILY_CRIT_NUM = 3,         //每天前三次暴击剩余次数，初始为最大值3
    MAX_PET_AWARD_FRUIT_NUM = 50, //用户升级宠物星级奖励的最大果实数量,理论最大100，实际升级中最多50个未领取
    MAX_PET_CAN_EAT_FRUIT = 100,   //宠物最大可吃果实数量

    PET_FRUIT_REVISE_FIGHTING_RATE = 10,//每个宠物果实修正星级战斗力的千分比

    CONST_PET_LEVEL_ATTRS = 10,     //等阶属性数量,最多10个
    CONST_PET_CRIT_EXPER = 10,      //宠物培养暴击倍率
    //宠物培养类型
    PET_TRAIN_TYPE_1 = 0,       //皇家口粮
    PET_TRAIN_TYPE_2 = 1,       //金币
    PET_TRAIN_TYPE_3 = 2,       //银币
    PET_TRAIN_TYPE_4 = 3,       //果实

    CONST_PET_FRUIT_BAT_NUM = 50,      //批量黄家口粮培养的数量
    PET_ENABLE_NEW_STYLE_NEED_GOLD = 500, //激活新形态需要的金币数

    //操作类型
    CONST_PET_EXPLORE = 0,      //宠物探险
    CONST_PET_CHANGE_STYLE = 1, //切换宠物形态
    CONST_PET_RENAME = 2,      //宠物改名
    CONST_PET_UPDATE_LEVEL = 3,      //请求宠物升等阶
    CONST_PET_RECV_FRUIT = 4,       //领取宠物果实
    CONST_PET_CLEAR_CD_TIME = 5,   //清除cd时间
    CONST_PET_ENABLE_NEW_STYLE = 6, //激活新形态

    CONST_PET_NOT_FRUIT_RECV = 0,      //没有果实领取
    CONST_PET_HAS_FRUIT_NOT_RECV = 1,      //有果实奖励但没领取
    //宠物相关----------------------end--------------

    //魔界门系统
    MAX_CONTRIBUTE_LIST = 3,        //充能次数前三名
    MAGIC_DOOR_LEVEL_CFG_COUNT = 6,//等级配置表总条目数量
    MAGIC_DOOR_LEVEL_ACT_GIFT_COUNT = 5,//等级配置表杀死BOSS礼包总数量
    MAGIC_DOOR_MAX_LEVEL = MAGIC_DOOR_LEVEL_CFG_COUNT - 1,//魔界门的最大等级
    MAGIC_DOOR_CONTRIBUTE_CFG_COUNT = 15,   //充能配置表总条目数量
    MAGIC_DOOR_MAX_PAY_TIMES = 15,  //每天最大充能次数 限于char存储 此值不能大于127
    MAX_MAGIC_DOOR_BOSS_NUMS = 50,  //魔界门Boss最多数量
    CONST_MONSTER_TYPE_COMMON = 1,//普通boss
    CONST_MONSTER_TYPE_SPECIAL = 2,//特殊boss

    //冥想相关
    MAX_MUSE_COUNT_TIME  = 15,  //冥想结算时间
    MAX_MUSE_VIP_CONFIG  = 15,  //冥想VIP最多配置项

    //坐骑相关
    MAX_MOUNT_CFG_COUNT  = 100,  //坐骑最多配置项
    MAX_MOUNT_BAG_SIZE   = 10,   //坐骑背包大小
    DEF_MOUNT_FREE_POS   = 2,    //缺省解锁的坐骑位
    MAX_ATTR_PER_MOUNT   = 3,    //最多的属性
    MAX_HUNT_SOUL_GRID   = 27,    //猎魂的格子数
    MAX_HUNT_PER_SILVER  = 100000, //猎魂一次需要的银币
    MAX_HUNT_PER_GOLD    = 10,    //猎魂一次需要的金币
    MAX_HUNT_BATCH_TIME  = 50,    //批量投掷的次数

    //冷却时间相关
    MAX_COOLING_CONFIG_COUNT = 50,

    //家族战
    CLAN_BATTLE_BATTLE_INTERVAL = 60 * 2, //家族战每2分钟结算一次
    CLAN_BATTLE_MAX_CLAN_COUNT = 80,
    CLAN_BATTLE_CLAN_MEMBER_COUNT = 10,

    CLAN_BATTLE_ROLE_RANK_COUNT = 10,       //个人排名数量
    CLAN_BATTLE_CLAN_RANK_COUNT = 10,       //家族排名数量
    CLAN_BATTLE_RECORDER_COUNT = 20,        //战斗记录数量

    //学院
    MAX_ACADEMY_RANK_COUNT = 5,             //学院排行榜记录数
    MAX_ACADEMY_NEWLY_ENTER_ROLENAME_COUNT = 15, //需记录多少个最近加入学院的玩家昵称

    //全服排行榜
    MAX_ZONE_RANK_COUNT = 200,             //排行榜记录数.

    //vip常量配置--------start
    MAX_VIP_AWARD_NUM                   = 10, //vip奖励数，最多5个
    MAX_VIP_LEVEL                       = 13, //vip最大等级数12,包含0级就是13
    MAX_VIP_MODULE_NUMS                 = 1000,  //付费目标项, 16(modules)*12(vip level)

    //付费目标项id
    VIP_MODULE_ID_1   =  1 , // 购买精力
    VIP_MODULE_ID_2   =  2 , // 炼金
    VIP_MODULE_ID_3   =  3 , // 免费炼金次数
    VIP_MODULE_ID_4   =  4 , // 精灵星尘购买次数
    VIP_MODULE_ID_5   =  5 , // 宝物探险购买次数
    VIP_MODULE_ID_6   =  6 , // 购买博物馆扫荡次数
    VIP_MODULE_ID_7   =  7 , // 精英副本重置权限
    VIP_MODULE_ID_8   =  8 , // 深层魔晶开采次数
    VIP_MODULE_ID_9   =  9 , // 宝箱争夺战打劫权限
    VIP_MODULE_ID_10  =  10, // 世界Boss类活动自动战斗权限
    VIP_MODULE_ID_11  =  11, // 怪物攻城类活动的自动补刀功能权限
    VIP_MODULE_ID_12  =  12, // 悬赏令任务可接受次数
    VIP_MODULE_ID_14  =  14, // 家族转盘次数
    VIP_MODULE_ID_15  =  15, // 上课次数购买权限
    VIP_MODULE_ID_16  =  16, // 魔药转移操作权限
    VIP_MODULE_ID_17  =  17, // 购买幸运闯关投骰
    VIP_MODULE_ID_18  =  18, // 购买家族神树浇水
    VIP_MODULE_ID_19  =  19, // 秘境副本重置
    VIP_MODULE_ID_20  =  20, // 一键占卜
    VIP_MODULE_ID_21  =  21, // 批量炼金
    VIP_MODULE_ID_22  =  22, // 批量魔晶开采
    VIP_MODULE_ID_23  =  23, // 一键榚家口粮
    VIP_MODULE_ID_24  =  24, // 消费返利
    VIP_MODULE_ID_25  =  25, // 金币占卜
    VIP_MODULE_ID_26  =  26, // 金字塔重置
    VIP_MODULE_ID_27  =  27, // 坐骑金币猎魂

    //操作类型
    CONST_VIP_DAILY_GIFT = 1,      //每日礼包
    CONST_VIP_LEVEL_GIFT = 2,      //等级礼包
    CONST_VIP_FIRST_PAY = 3,       //首充礼包

    FIRST_PAY_GIFT_ID = 238,           //首充礼包ID

    //礼包状态
    CONST_VIP_GIFT_NONE     = 0,       //礼包不可领取
    CONST_VIP_GIFT_OPENED   = 1,       //礼包已经领取
    CONST_VIP_GIFT_CAN_OPEN = 2,       //礼包可领取
    //vip常量配置--------end

    //怪物攻城战配置
    MAX_ENEMY_ATK_CITY_ROUND_COUNT = 200,    //总共有几波怪
    MAX_ENEMY_ATK_CITY_COUNT_PER_ROUND = 20,         //一波最多20个怪
    MAX_ENEMY_ATK_CITY_FIRST_ROUND_WAIT_SECS = 3 * 60, //第一轮开始前的准备时间
    MAX_ENEMY_ATK_CITY_LAST_SECS = 33 * 60,     //活动持续时间
    MAX_ENEMY_ATK_CITY_ROLE_RANK_COUNT = MAX_REGISTER_PLAYER,    //个人排行榜数量
    MAX_ENEMY_ATK_CITY_DIE_CD = 30,             //死亡冷却秒数
    MAX_ENEMY_ATK_CITY_MAP_ID = 5010001,           //战斗地图
    MAX_ENEMY_ATK_CITY_FIGHT_COOL_DOWN = 10,        //战斗冷却时间
    ENEMY_ATK_CITY_BLESS_STATUS_ID = 1035,               //祝福用状态ID
    ENEMY_ATK_CITY_BLESS_PRICE = 2,             //祝福价格

    MAP_ID_CLAN_HALL = 5030001,           //家族大厅的地图
    MAP_ID_AUCTION   = 5040001,           //拍卖会地图ID
    MAP_ID_INS       = 999999999,           //假的副本地图

    //家族闯关--start-----------
    //格子类型
    CONST_GRID_TYPE_LEVEL_START             = 0, //每一层的起始格子
    CONST_GRID_TYPE_AWARD                   = 1, //奖励
    CONST_GRID_TYPE_ADD_ONE_TIMES           = 2, //投骰次数+1
    CONST_GRID_TYPE_SHAKE_TWO_DICE          = 3, //投掷2个骰子

    CONST_DICE_GRIDS_ONE_LAYER  = 5,        //每层的格子数
    CONST_DICE_AWARD_BASE_RATE  = 10,       //根据级别奖励的系数基数
    CONST_DAILY_DICE_COUNTS = 10,           //每日可以免费投骰子的次数
    CONST_DAILY_DICE_BUY_COUNTS = 10,       //每日可以购买投骰子的次数
    MAX_DICE_GRID_NUMS      = 500,          //格子的最大个数,
    MAX_DICE_PAY_NUMS       = 20,           //可以金币购买的最大次数
    MAX_DICE_LEVEL_NUMS     = 100,           //最多层级数
    MAX_DICE_LEVEL_AWARD_NUM    = 3,        //每层最大奖励物品数
    MAX_DICE_RANK_SIZE    = 10,             //闯关排行榜大小
    //家族闯关--end-----------

    //拍卖会--------------start----------
    //拍卖活动类型

    MAX_AUCTION_PUBLIC_ROUNDS    =   6,      //每天竞拍(包括压轴竞拍)的最多轮次.
    MAX_AUCTION_ROLL_MSG       = 3,         //出价记录数
    MAX_AUCTION_MAR_MSG        = 3,         //跑马灯信息数

    MAX_AUCTION_FINAL_DAYS     =   7,      //压轴竞拍商品的特殊配置最多开服天数

    AUCTION_RESET_TIME  =   0,           //拍卖会数据重置时间
    AUCTION_GOLD_PRICE_UNIT    = 10,     //拍卖会金币出价单位
    AUCTION_SILVER_PRICE_UNIT  = 100000, //拍卖会银币出价单位

    MAX_AUCTION_GOODS_NUM   = 300,        //最多拍卖商品的配置数量
    MAX_AUCTION_FINAL_GOODS      = 100,   //压轴竞拍商品最多的配置数量
    MAX_AUCTION_PULIC_GOODS      = 100,   //竞拍商品最多的配置数量
    MAX_AUCTION_BLIND_GOODS      = 100,   //暗拍商品最多的配置数量
    MAX_AUCTION_MAR_TIME         = 300,   //竞价商品结束的最后5分钟，开始实况播放走马灯
    //拍卖会--------------end----------

    //许愿池
    CONST_WISH_NUM = 3, //许愿次数
    CONST_WISH_PAY_GOLD10 = 10,     //10金币
    CONST_WISH_PAY_GOLD50 = 50,     //50金币
    CONST_WISH_PAY_SILVER = 10000,     //10000银币
    MAX_WISH_NUM = 10,      //没类型许愿的概率分布数量

    //离线消息
    MAX_OFFLINE_TIPS_COUNT = 50,        //离线TIPS数量
    MAX_OFFLINE_ITEM_COUNT = MAX_DROP_ITEM_PER_TIME,        //离线物品数量

    //精彩活动
    MAX_SPLENDID_ACT_COUNT = 30,        //精彩活动最大数量
    MAX_SPLENDID_CRYCOMBINE_LEVEL_COUNT = 5, //魔晶合成赢幸运活动等级配置数量
    MAX_SPLENDID_CLAN_RANK_COUNT = 20,        //全服家族排名活动排名最大个数
    MAX_SPLENDID_EAC_TARGETS_COUNT = 5,       //怪物攻城连杀奖励任务目标最大个数
    MAX_SPLENDID_BUY_GOLD_SEND_CRY = 5,       //充值送魔晶活动获得的礼包种类数
    MAX_SPLENDID_ZQ_GIFT_COUNT    = 7,          //中秋活动礼包数量
    MAX_SPLENDID_PAY_RANK_COUNT = 7,     //消费排名奖励数量 注意使用unsigned char存储 不应超过7个
    MAX_SPLENDID_GQ_LOGIN_DAYS = 7,      //国庆登录7天有奖励
    MAX_SPLENDID_GQ_GET_CARD_COUNT = 8,  //国庆集卡，卡片数量
    MAX_SPLENDID_GQ_GET_CARD_BONUS_COUNT = 4, //国庆集卡，奖励数量（组合数量）
    MAX_SPLENDID_GOLD_CARD_MAX_RANK = 10,     //金秋猎奇，排名数量
    MAX_SPLENDID_LUCKY_DIAL_ITEM_COUNT = 15,  //幸运转盘背包物品数量上限
    MAX_SPLENDID_LUCKY_DIAL_FREE_ROLL = 2,    //幸运转盘免费摇奖次数
    MAX_SPLENDID_SD_BIG_BONUS_COUNT = 3,    //双蛋活动单服圣诞大奖产出上限
    MAX_SPLENDID_SD_RECORD_COUNT = 10,    //双蛋活动单服物品记录上限
    MAX_SPLENDID_SD_RANK_COUNT = 5,       //双蛋活动单服充值排名上限
    MAX_SPLENDID_ROCK_NUM_COUNT = 4,      //摇摇乐活动数字单元
    MAX_SPLENDID_ROCK_RECORD_COUNT = 10,  //摇摇乐活动单服物品记录上限 //因为这个数量与MAX_SPLENDID_SD_RECORD_COUNT所以CTRankArray虚函数复用
    MAX_SPLENDID_ROCK_RANDOM_GIFT = 3,      //摇摇乐活动概率礼包数
    MAX_SPLENDID_ROCK_EXCHANGE_GIFT = 6,    //摇摇乐活动兑换礼包数 注意有存储 不能往小的改

    MAX_SPLENDID_RED_PACKET_ACT_DAY_COUNT = 14, //领红包活动总天数 不存储的宏值 用于代码中判断时长
    MAX_SPLENDID_RED_PACKET_DB_DAY_COUNT = 14, //领红包活动总天数 注意有存储 不能往小的改
    MAX_SPLENDID_RED_PACKET_BACK_RATIO = 100, //领红包活动返还千分比

    //黄钻相关
    MAX_YELLOW_LEVEL = 8,                                  //最高黄钻等级
    MAX_YELLOW_LEVEL_GIFT_COUNT = MAX_ROLE_LEVEL / 10,     //黄钻等级礼包最大数量
    MAX_YELLOW_DEFAULT_VIP_LEVEL = 1,                      //黄钻用户缺省vip等级
    MAX_3366_LEVEL_COUNT = 6,                              //3366礼包等级段数量

    //蓝钻相关
    MAX_BLUE_LEVEL = 8,                                  //最高蓝钻等级
    MAX_BLUE_LEVEL_GIFT_COUNT = MAX_ROLE_LEVEL / 10,     //蓝钻等级礼包最大数量
    MAX_BLUE_DEFAULT_VIP_LEVEL = 1,                      //蓝钻用户缺省vip等级

    //购买金币
    MAX_BUY_GOLD_CONFIG_COUNT = 5,     //金币配置数量

    //金字塔活动
    MAX_PYRAMID_LEVEL       = 9,        //金字塔最高多少层
    MAX_PYRAMID_COUNT       = 5,        //总共有多少个金字塔
    MAX_PYRAMID_MONSTER_BONUS_COUNT = 5, //击杀怪物奖励种类数
    MAX_PYRAMID_POS_COUNT = 45,     //最多的格子数

    //QQ商城
    MAX_GOODS_DESC_STRING_SIZE  = 64,    //商品描述字符串长度
    MAX_GOODS_CONFIG_NUM       =  500,    //最多的商品配置项
    MAX_QUICK_BUY_GOODS_NUM    =  50,     //最多的快捷购买配置项
    MAX_TAB_GOODS_CFG_PROP     =  100,    //道具商品最多的配置数
    MAX_TAB_GOODS_NUM_PROP     =  MAX_TAB_GOODS_CFG_PROP,    //道具商品最多的上架商品数
    MAX_TAB_GOODS_CFG_CRYSTAL     =  200,    //魔晶商品最多的配置数
    MAX_TAB_GOODS_NUM_CRYSTAL     =  MAX_TAB_GOODS_CFG_CRYSTAL,    //魔晶商品最多的上架商品数
    MAX_TAB_GOODS_CFG_LIMITED   =  200,    //限时专区最多的配置数
    MAX_TAB_GOODS_NUM_LIMITED   =  50,     //限时专区最多的上架商品数
    MAX_TAB_GOODS_CFG_HOT   =  100,    //热卖专区最多的配置数
    MAX_TAB_GOODS_NUM_HOT   =  MAX_TAB_GOODS_CFG_HOT,     //热卖专区最多的上架商品数
    MAX_LIMIT_GOODS_MEANWHILE = 10,   //最多同时出后的限价商品
    MAX_TAB_GOODS_CFG_MOUNT   =  100,    //坐骑商品最多的配置数
    MAX_TAB_GOODS_CFG_FASHION  =  50,     //时装商品最多的配置数
    MAX_MOUNT_CAN_BUY        = 9,       //最多可累计购买的坐骑数

    //OSS账单
    MAX_OSS_ITEM_STRING_LEN = 2048, //OSS账单物品字符串长度
    MAX_BIT_SET_STRING_LEN = 512, //公用的用于设置位的字符串长度

    //每日签到
    MAX_DAY_SIGN_CONTINUE_COUNT = 5, //连续签到奖励礼包数 若增大不能大于8
    MAX_DAY_SIGN_CONTINUE_TIMES = 7, //连续签到上限值
    MAX_DAY_SIGN_ACCUMULATE_COUNT = 5, //累计签到要求与奖励数 若增大不能大于32
    MAX_DAY_SIGN_ACCUMULATE_TIMES = 31, //累计签到上限值

    MAX_DAY_WISH_CONFIG_COUNT = 50, //每日许愿奖励配置数量
    MAX_DAY_WISH_ITEM_COUNT = 5, //每日许愿奖励数量
    //家族转盘
    CLAN_DAIL_GIFT_ID       = 335,      //家族转盘的礼包ID
    CLAN_DAIL_NEED_CONTRI   = 20,       //家族转盘需要消耗的贡献度
    CLAN_DAIL_RESET_TIME    = 0,        //家族转盘次数重置时间

    //魔晶潜能
    MAX_CRYSTAL_POTENTIAL_LEVEL     = 50,      //潜能最高的等级
    CRYSTAL_POTEN_MATERIAL_ID       = 194,     //魔晶精华的材料ID

    //支付相关
    MAX_GROW_FUND_TYPE = 6,              //成长基金奖励类型
    GROW_FUND_GOODS_ID = 42,             //成长基金商品ID

    //新手目标
    MAX_NEWBIE_TASK_DAYS = 7,  //新手天数
    MAX_NEWBIE_TASK_COUNT_PER_DAY = 3, //1天3个任务
    MAX_NEWBIE_TASK_CONFIG_COUNT = MAX_NEWBIE_TASK_DAYS * MAX_NEWBIE_TASK_COUNT_PER_DAY,

    NEWBIE_TASK_COND_1 = 1,         //主角等级 - 等级
    NEWBIE_TASK_COND_2 = 2,         //宠物星阶 - 等阶 * 10 + 星级
    NEWBIE_TASK_COND_3 = 3,         //击败怪物组  - 怪物组ID
    NEWBIE_TASK_COND_4 = 4,         //装备强化等级 - 件数 * 100 + 装备等级
    NEWBIE_TASK_COND_5 = 5,         //魔晶镶嵌 - 几颗 * 10 + 魔晶等级
    NEWBIE_TASK_COND_6 = 6,         //学习家族技能 - 家族技能等级
    NEWBIE_TASK_COND_7 = 7,         //魔药炼满 - 瓶数 * 10 + 魔药等级
    NEWBIE_TASK_COND_8 = 8,         //在竞技场中获取 - 胜利次数
    NEWBIE_TASK_COND_9 = 9,         //合成卡片 - 卡片类型 * 10 + 卡片等级
    NEWBIE_TASK_COND_10 = 10,       //家族星门充能 - 家族星门充能次数
    NEWBIE_TASK_COND_11 = 11,       //魂器等级 - 魂器等级
    NEWBIE_TASK_COND_12 = 12,       //参与怪物攻城活动 - 参加次数
    NEWBIE_TASK_COND_13 = 13,       //在世界boss活动中购买梅林祝福 - 购买次数

    //宝箱争夺战
    MAX_FIGHT_FOR_BOX_BOX_COUNT = 24,   //箱子数量
    MAX_FIGHT_FOR_BOX_ROLE_COUNT = 3,    //参与角色数
    MAX_FIGHT_FOR_BOX_BONUS_COUNT = 6,   //可兑换奖励数量
    MAX_FIGHT_FOR_BOX_NPC_COUNT = 6,     //NPC的数量
    MAX_FIGHT_FOR_BOX_CAN_BUY_EYE_COUNT = 3, //最大可购买慧眼个数

    //一战到底
    MAX_FIGHT_END_CONFIG_COUNT = 10, //配置上限
    MAX_FIGHT_END_AWARD_COUNT = 2,   //奖励数量
    MAX_FIGHT_END_ROLE_SIDE = 3,     //一方人数
    MAX_FIGHT_END_ROLE_TOTAL = MAX_FIGHT_END_ROLE_SIDE * 2,    //总参战人数

    //学院杯
    MAX_ACA_CAP_ROLE_COUNT = 5000, //最多参与人数
    MAX_ACA_CAP_FIRST_STAT_ROUND = 20, //淘汰赛最大轮数
    MAX_ACA_CAP_SECOND_ROLE_COUNT = 32, //决赛32强
    MAX_ACA_CAP_SECOND_STAT_COUNT = 5, //决赛一回合最多打5轮
    MAX_ACA_CAP_SECOND_ROUND = 5, //32强，最多5轮,该值只能扩大
    MAX_ACA_CAP_INSPIRE_STATUS_ID = 1036, //祝福状态ID
    MAX_ACA_CAP_INSPIRE_BUFF_VALID_SEC = 5 * 3600, //祝福状态有效时间

    //领地战
    MAX_MANOR_BATTLE_SCENE_COUNT = 3, //场景数量
    MAX_MANOR_BATTLE_MONSTER_COUNT = 3, //怪物数量
    MAX_MANOR_BATTLE_DEFEND_RANK = 3, //防守方积分排名总数
    MAX_MANOR_BATTLE_ATTACK_RANK = 3, //攻击方积分排名总数
    MAX_MANOR_BATTLE_ATK_CLAN_RANK = 10, //攻击方家族积分排名总数
    MAX_MANOR_BATTLE_ATK_CLAN_COUNT = 10, //参战家族总数
    MAX_MANOR_BATTLE_ACT_CLAN_COUNT = 11, //参战家族总数
    ENM_MANOR_BATTLE_CAMP_NONE = 0,     //无阵营 表示家族不能参加活动
    ENM_MANOR_BATTLE_CAMP_DEFEND = 1,   //防守阵营
    ENM_MANOR_BATTLE_CAMP_ATTACK = 2,   //进攻阵营
    MAX_MANOR_BATTLE_DEFEND_LIST = 30,  //防守方目标总数
    MAX_MANOR_BATTLE_ATTACK_LIST = 100, //攻击方目标总数
    MAX_MANOR_BATTLE_INFO_COUNT = 20,   //传递参数数量
    MAX_MANOR_BATTLE_ITEM_COUNT = 2,   //奖励物品配置数量
    MAX_MANOR_BATTLE_RECORD_COUNT = 20,  //奖励条目配置数量

    DEFAULT_GOODS_ID_32WAN = 91,             //32玩充值符石使用的商品ID

    //时装
    MAX_WING_BAG_SIZE = 12,   //翅膀背包大小
    MAX_DRESS_BAG_SIZE = 12,   //装扮背包大小};

    //奖励找回
    MAX_REWARD_BACK_DAY_COUNT = 8,  //找回天数 实际上是7+1 因为当前的记录要到24点之后才能找回

    //登录奖励
    MAX_LOGIN_REWARD_DAY_COUNT = 7,  //登录天数
    MAX_LOGIN_REWARD_ITEM_COUNT = 7, //奖励数量
};

//系统缺省值
enum enumSystemDefData
{
    SYS_DEFAULT_GRID_NUM_BAG = 42,         //系统为用户缺省打开的背包格子数
    SYS_DEFAULT_GRID_NUM_WAREHOUSE = 18,   //系统为用户缺省打开的仓库格子数
    SYS_DEFAULT_EQUIP_DESC_LEVEL = 5,      //装备后,强化减少的等级
    SYS_DEFAULT_EQUIP_STRENGTH_LEVEL = 1,  //新装备默认的强化等级
    SYS_DEFAULT_NEED_CRYSTAL_FRAG_CNT = 6, //碎片合成
};

enum PLAYER_CAREER
{
    CAREER_BEGIN = 1,

    CAREER_1 = 1,       //魔剑士 sword
    CAREER_2 = 2,       //魔法师 mage
    CAREER_3 = 3,       //魔猎手 bow
    CAREER_4 = 4,       //魔斗士 awl

    CAREER_END = 4,
};

//物品操作标识
enum ITEM_OPER_FLAG
{
    ITEM_OPER_NONE      = 0,
    ITEM_OPER_SELL      = 1 << 0,  //是否可出售
    ITEM_OPER_DISCARD   = 1 << 1,  //是否可丢弃
    ITEM_OPER_EXPENSIVE = 1 << 3,  //是否贵重物品
    ITEM_OPER_MAX       = 1 << 7,  //最大的操作类型
};

//物品的类型
enum ITEM_TYPE
{
    ITEM_TYPE_MIN = 1,

    ITEM_TYPE_NULL = 0,         //无效的物品类型
    ITEM_TYPE_EQUIP = 1,        //装备
    ITEM_TYPE_EXP = 2,          //经验(主角和伙伴, 战斗用)
    ITEM_TYPE_SILVER = 3,       //银币
    ITEM_TYPE_GOLD  = 4,        //金币
    ITEM_TYPE_HUNLI = 5,        //魂力
    ITEM_TYPE_LILIAN = 6,       //历练
    ITEM_TYPE_SCROLL = 7,       //卷轴
    ITEM_TYPE_MATERIAL = 8,     //材料
    ITEM_TYPE_CRYSTAL = 9,      //魔晶
    ITEM_TYPE_CARD = 10,        //卡片
    ITEM_TYPE_REPUTATION = 11,  //声望
    ITEM_TYPE_EXP_ROLE = 12,    //主角经验
    ITEM_TYPE_EXP_PARTNER = 13,  //伙伴经验
    ITEM_TYPE_LEVEL_EXP = 14,    //由等级决定的经验， 发给队伍
    ITEM_TYPE_LEVEL_SILVER = 15, //由等级决定的银币
    ITEM_TYPE_CLAN_EXP = 16,     //家族获得的额外经验
    ITEM_TYPE_CLAN_SILVER = 17,  //家族获得的额外银币
    ITEM_TYPE_CRYSTAL_FRAG = 18, //魔晶碎片
    ITEM_TYPE_JEWEL = 19,     //宝石
    ITEM_TYPE_SOLVENT = 20,   //岩石溶剂
    ITEM_TYPE_TREASURE = 21,  //秘宝
    ITEM_TYPE_GIFT  = 22,   //礼包
    ITEM_TYPE_FRUIT = 23,   //宠物果实
    ITEM_TYPE_SPIRIT = 24,  //秘宝灵力
    ITEM_TYPE_SEAL  = 25,   //宝石印记(宝石商店中使用)
    ITEM_TYPE_DROP1 = 26,        //等级相关的物品集合1(装备卷轴)
    ITEM_TYPE_DROP2 = 27,        //等级相关的物品集合2(装备主材)
    ITEM_TYPE_DROP3 = 28,        //等级相关的物品集合3(装备辅材)
    ITEM_TYPE_CONTRIBUTION  = 29,  //家族贡献度
    ITEM_TYPE_LESSON_POINT = 30,   //学分
    ITEM_TYPE_DROP4 = 31,        //等级相关的物品集合4(魔药主材)
    ITEM_TYPE_EXA_EXP = 32,      //扫荡副本额外的经验奖励(前台展示用)
    ITEM_TYPE_EXA_SILVER = 33,   //扫荡副本额外的银币奖励(前台展示用)
    ITEM_TYPE_CARD2     = 34,    //卡片前台（前台展示用）
    ITEM_TYPE_ENERGY     = 35,    //精力
    ITEM_TYPE_USABLE     = 36,    //背包中可使用物品
    ITEM_TYPE_PARTNER    = 37,    //伙伴
    ITEM_TYPE_LEVEL_ITEM = 38,    //由等级决定物品. (物品ID为1: 洗炼符文)
    ITEM_TYPE_MOUNT      = 39,    //使用物品得到坐骑
    ITEM_TYPE_BLESS_POINT = 40,   //装备祝福点
    ITEM_TYPE_USE_GOLD_POINT = 41,  //消费返利点数
    ITEM_TYPE_MOUNT_SOUL = 42,      //坐骑骑魂
    ITEM_TYPE_FASHION = 43,      //时装
    ITEM_TYPE_MANOR_SCORE = 44,  //领地战积分
    ITEM_TYPE_MAX = 44,

    //注意: 新增物品类型时修改item.xlx表
    //注意: 新增物品类型时需要这几处:  1.) 增加物品. CCmdDropItem::LogicDo.
    //                              2.) 物品在背包中的排序权值. CItemMgr::GetConfig
    //                              3.) 物品出售\购买价格 CItemMgr::GetItemPrice.
};

enum EN_LEVEL_DROP_ITEM_SUB_TYPE
{
    LEVLE_DROP_ITEM_MIN = 1,
    LEVLE_DROP_ITEM_MAX = 1,

    LEVEL_DROP_EQUIP_REFINE = 1,
};

//系统开放条件类型
enum ENUM_SYS_OPEN_COND_TYPE
{
    SYS_OPEN_COND_TYPE_NULL = 0,                //空
    SYS_OPEN_COND_TYPE_FINISH_TASK = 1,         //完成任务
    SYS_OPEN_COND_TYPE_GET_AND_FINISH_TASK = 2, //完成或接取任务
    SYS_OPEN_COND_TYPE_LEVEL = 3,               //等级
    SYS_OPEN_COND_TYPE_VIP_LEVEL = 4,           //VIP等级
    SYS_OPEN_COND_TYPE_FESTIVAL = 5,           //处在节日活动时间段内

    SYS_OPEN_COND_TYPE_MAX = 5,                 //
};

//系统开放条件ID, 定义看sysopen.xlsx配置
enum ENUM_SYS_OPEN_ID
{
    SYS_OPEN_COND_ID_NULL = 0,                //空
    SYS_OPEN_COND_ID_1 = 1,         //阵型功能开启
    SYS_OPEN_COND_ID_2 = 2,         //强化功能
    SYS_OPEN_COND_ID_3 = 3,         //宠物功能开启
    SYS_OPEN_COND_ID_4 = 4,         //好友功能开启
    SYS_OPEN_COND_ID_5 = 5,         //魂器功能开启
    SYS_OPEN_COND_ID_6 = 6,         //上课-必修课
    SYS_OPEN_COND_ID_7 = 7,         //购买体力功能开启
    SYS_OPEN_COND_ID_8 = 8,         //炼金功能开启
    SYS_OPEN_COND_ID_9 = 9,         //有求必应屋--经验
    SYS_OPEN_COND_ID_10 = 10,       //魔晶镶嵌功能开启
    SYS_OPEN_COND_ID_11 = 11,       //家族功能开启
    SYS_OPEN_COND_ID_12 = 12,       //冥想功能开启
    SYS_OPEN_COND_ID_13 = 13,       //竞技场功能开启
    SYS_OPEN_COND_ID_14 = 14,       //魔药-炼制功能开启
    SYS_OPEN_COND_ID_15 = 15,       //上课-选修课功能开启
    SYS_OPEN_COND_ID_16 = 16,       //秘境功能开启
    SYS_OPEN_COND_ID_17 = 17,       //魔晶开采功能开启
    SYS_OPEN_COND_ID_18 = 18,       //有求必应屋--银币
    SYS_OPEN_COND_ID_19 = 19,       //占卜功能开启
    SYS_OPEN_COND_ID_20 = 20,       //秘宝功能开启
    SYS_OPEN_COND_ID_21 = 21,       //博物馆功能开启
    SYS_OPEN_COND_ID_22 = 22,       //魔药-提纯功能开启
    SYS_OPEN_COND_ID_23 = 23,       //扫荡功能开启
    SYS_OPEN_COND_ID_24 = 24,       //宠物探险功能开启
    SYS_OPEN_COND_ID_25 = 25,       //坐骑系统
    SYS_OPEN_COND_ID_26 = 26,       //时装功能
    SYS_OPEN_COND_ID_27 = 27,       //家族技能
    SYS_OPEN_COND_ID_28 = 28,       //小秘书
    SYS_OPEN_COND_ID_29 = 29,       //许愿池
    SYS_OPEN_COND_ID_30 = 30,       //精英副本
    SYS_OPEN_COND_ID_31 = 31,       //神秘商店
    SYS_OPEN_COND_ID_32 = 32,       //学院试炼
    SYS_OPEN_COND_ID_33 = 33,       //日常活动
    SYS_OPEN_COND_ID_34 = 34,       //吃饭系统
    SYS_OPEN_COND_ID_35 = 35,       //怒气系统
    SYS_OPEN_COND_ID_36 = 36,       //拍卖会
    SYS_OPEN_COND_ID_37 = 37,       //技能系统
    SYS_OPEN_COND_ID_38 = 38,       //花园购买土地
    SYS_OPEN_COND_ID_39 = 39,       //黄钻特权
    SYS_OPEN_COND_ID_40 = 40,       //装备合成
    SYS_OPEN_COND_ID_41 = 41,       //经验树
    SYS_OPEN_COND_ID_42 = 42,       //送符石
    SYS_OPEN_COND_ID_43 = 43,       //金字塔
    SYS_OPEN_COND_ID_44 = 44,       //每日签到和每日许愿
    SYS_OPEN_COND_ID_45 = 45,       //家族活动
    SYS_OPEN_COND_ID_46 = 46,       //成长基金
    SYS_OPEN_COND_ID_47 = 47,       //在线奖励
    SYS_OPEN_COND_ID_49 = 49,       //学院之星
    SYS_OPEN_COND_ID_50 = 50,       //消费返利
    SYS_OPEN_COND_ID_51 = 51,       //餐厅
    SYS_OPEN_COND_ID_52 = 52,       //首充活动
    SYS_OPEN_COND_ID_53 = 53,       //精彩活动
    SYS_OPEN_COND_ID_54 = 54,       //节日活动
    SYS_OPEN_COND_ID_55 = 55,       //宝箱争夺
    SYS_OPEN_COND_ID_56 = 56,       //QQ好友邀请
    SYS_OPEN_COND_ID_57 = 57,       //一战到底
    SYS_OPEN_COND_ID_58 = 58,       //悬赏任务
    SYS_OPEN_COND_ID_59 = 59,       //装备洗练
    SYS_OPEN_COND_ID_60 = 60,       //装备祝福
    SYS_OPEN_COND_ID_61 = 61,       //3366每日礼包
    SYS_OPEN_COND_ID_62 = 62,       //开服魔晶特卖
    SYS_OPEN_COND_ID_63 = 63,       //学院杯
    SYS_OPEN_COND_ID_64 = 64,       //感恩节砸蛋活动
    SYS_OPEN_COND_ID_65 = 65,       //奖励找回
    SYS_OPEN_COND_ID_66 = 66,       //登录奖励

    SYS_OPEN_COND_ID_MAX = 80,                 //
};

//物品存放位置
enum ENUM_STORAGE_TYPE
{
    STORAGE_TYPE_BAG  = 1,   //背包
    STORAGE_TYPE_WARE = 2,   //仓库
    STORAGE_TYPE_PARTNER = 3, //伙伴身上
    STORAGE_TYPE_GROUD = 4,  //地上
    STORAGE_TYPE_ROLE_EQUIP = 5,   //主角身上的装备
    STORAGE_TYPE_CARD = 6,   //卡片背包
    STORAGE_TYPE_ROLE_CARD = 7, //主角身上的卡片
    STORAGE_TYPE_TREASURE = 8, //秘宝背包
    STORAGE_TYPE_ROLE_TREASURE = 9, //人身上的秘宝(前台用)
    STORAGE_TYPE_SHOP_BUY = 10, //商店里面(前台用)
    STORAGE_TYPE_CLAN = 11, //家族背包
    STORAGE_TYPE_WING = 12, //翅膀背包
    STORAGE_TYPE_DRESS = 13, //装扮背包
    STORAGE_TYPE_LUCKY_DIAL = 14, //幸运转盘
};

//装备等级
enum ENUM_EQUIP_LEVEL
{
    EQUIP_LEVEL_NONE  = 0,   //无效值
    EQUIP_LEVEL_1     = 1,   // 1级套装
    EQUIP_LEVEL_20    = 2,   //20级套装
    EQUIP_LEVEL_40    = 3,   //40级套装
    EQUIP_LEVEL_60    = 4,   //60级套装
    EQUIP_LEVEL_80    = 5,   //80级套装
    EQUIP_LEVEL_90    = 6,   //90级套装
    EQUIP_LEVEL_100   = 7,   //100级套装
    EQUIP_LEVEL_110   = 8,   //110级套装
    EQUIP_LEVEL_120   = 9,   //120级套装
    EQUIP_LEVEL_130   = 10,  //130级套装
    EQUIP_LEVEL_140   = 11,  //140级套装
    EQUIP_LEVEL_150   = 12,  //150级套装
    EQUIP_LEVEL_MAX   = 13,  //最高等级
};

//装备位置
enum ENUM_EQUIP_POS
{
    EQUIP_POS_MONE          = 0,        //无效的装备位
    EQUIP_POS_HELMET        = 1,        //头盔
    EQUIP_POS_CLOTH         = 2,        //衣服
    EQUIP_POS_WEAPON        = 3,        //武器
    EQUIP_POS_SHOES         = 4,        //鞋子
    EQUIP_POS_NECKLACE      = 5,        //项链
    EQUIP_POS_RING          = 6,        //戒指
    EQUIP_POS_AMULET        = 7,        //护符
    EQUIP_POS_SEAL          = 8,        //纹章
    EQUIP_POS_MAX           = 8,        //最大的装备位
};

//卷轴的使用方式
enum ENUM_SCROLL_USE
{
    SCROLL_USE_SILVER = 1,   //银币合成
    SCROLL_USE_GOLD   = 2,   //金币合成
};

//礼包的添加方式
enum ENUM_ADD_GIFT_OPT
{
    ADD_GIFT_BAG     = 0,   //直接添加到背包中
    ADD_GIFT_COEXIST = 1,   //共存添加到待领取的奖励中
    ADD_GIFT_MUTEX   = 2,   //互斥添加到待领取的奖励中
};

//主角和伙伴装备位建议区分编码
//主角装备位置
enum ENUM_PLAYER_EQUIP_POS
{
    PLAYER_EQUIP_POS_MIN            = 1,        //主角装备位最小值用于下标检查
    PLAYER_EQUIP_POS_HELMET         = EQUIP_POS_HELMET,         //头盔
    PLAYER_EQUIP_POS_CLOTH          = EQUIP_POS_CLOTH,          //衣服
    PLAYER_EQUIP_POS_WEAPON         = EQUIP_POS_WEAPON,         //武器
    PLAYER_EQUIP_POS_SHOES          = EQUIP_POS_SHOES,          //鞋子
    PLAYER_EQUIP_POS_NECKLACE       = EQUIP_POS_NECKLACE,       //项链
    PLAYER_EQUIP_POS_RING           = EQUIP_POS_RING,           //戒指
    PLAYER_EQUIP_POS_AMULET         = EQUIP_POS_AMULET,         //护符
    PLAYER_EQUIP_POS_SEAL           = EQUIP_POS_SEAL,           //纹章
    PLAYER_EQUIP_POS_MAX            = 8,        //主角装备位最大值用于下标检查
};

//伙伴装备位置
enum ENUM_PARTNER_EQUIP_POS
{
    PARTNER_EQUIP_POS_MIN           = 1,        //伙伴装备位最小值用于下标检查
    PARTNER_EQUIP_POS_HELMET        = EQUIP_POS_HELMET,         //头盔
    PARTNER_EQUIP_POS_CLOTH         = EQUIP_POS_CLOTH,          //衣服
    PARTNER_EQUIP_POS_WEAPON        = EQUIP_POS_WEAPON,         //武器
    PARTNER_EQUIP_POS_SHOES         = EQUIP_POS_SHOES,          //鞋子
    PARTNER_EQUIP_POS_NECKLACE      = EQUIP_POS_NECKLACE,       //项链
    PARTNER_EQUIP_POS_RING          = EQUIP_POS_RING,           //戒指
    PARTNER_EQUIP_POS_AMULET        = EQUIP_POS_AMULET,         //护符
    PARTNER_EQUIP_POS_SEAL          = EQUIP_POS_SEAL,           //纹章
    PARTNER_EQUIP_POS_MAX           = 8,        //伙伴装备位最大值用于下标检查
};

//腾讯平台登录来源
enum TENCENT_LOGIN_FROM
{
    TENCENT_LOGIN_FROM_UNKNOWEN = 0,
    TENCENT_LOGIN_FROM_QZONE = 1,
    TENCENT_LOGIN_FROM_PENGYOU = 2,
    TENCENT_LOGIN_FROM_QQGAME = 3,
    TENCENT_LOGIN_FROM_3366 = 4,
};

//魔药相关
enum ENUM_MAKE_DRUG_TYPE
{
    MAKE_DRUG_SYNTHETIZE = 2, //魔药合成:2,
    MAKE_DRUG_PURIFY = 3,     //魔药提纯:3
};

//魔药操作方式
enum ENUM_DRUG_OPER_TYPE
{
    MAKE_DRUG_PREVEIW = 1, //预览信息: 1
    MAKE_DRUG_GOLD = 2,    //使用金币: 2
    MAKE_DRUG_NORMAL = 3,  //使用银币: 3
};

#define DRUG_ADD_SURPRISE_PURITY_PERCENT  10   //额外提升纯度值为10%

//提纯特殊事件
enum ENUM_DRUG_PURIFY_SURPRISE
{
    DRUG_PURIFY_SURPRISE_NONE = 0,  //没有收获
    DRUG_PURIFY_SURPRISE_PURITY = 1,  //额外提升10%纯度
    DRUG_PURIFY_SURPRISE_MONEY = 2,   //返还20%的银币或金币
    MAX_PURIFY_SURPRISE_EVENT  = 3,   //不同的额外事件数
};

//提纯特殊事件概率
enum ENUM_DRUG_PURIFY_SURPRISE_RATE
{
    DRUG_PURIFY_SURPRISE_RATE_NONE = 50,  //没有收获的概率
    DRUG_PURIFY_SURPRISE_RATE_PURITY = 10,  //额外提升10%纯度的概率
    DRUG_PURIFY_SURPRISE_RATE_MONEY = 40,   //返还20%的银币或金币的概率
};

//战斗队伍
enum ENUM_BATTLE_TEAM
{
    BATTLE_TEAM_RIGHT  = 0,     //右方队伍
    BATTLE_TEAM_LEFT  = 1,      //左方队伍
};

//战斗结果
enum ENUM_BATTLE_RESULT
{
    BATTLE_RESULT_TIE  = 2,     //平局
    BATTLE_RESULT_WIN  = 1,     //左方胜
    BATTLE_RESULT_LOST  = 0,    //左方败
};

//战斗概率修正
enum ENUM_BATTLE_RATE_AMEND
{
    BATTLE_RATE_SKILL_PERCENT = 1000,   //技能千分比
    BATTLE_RATE_SKILL_PC_MIN = 50,      //技能保底千分比
    BATTLE_RATE_ATK_VAL_MIN = 30,       //伤害下限
    BATTLE_RATE_HIT_AMEND_MIN = 500,    //保底命中概率值
    BATTLE_RATE_BLOW_AMEND_MIN = 500,   //保底破击概率值
    BATTLE_RATE_DOUBLE_AMEND_MIN = 100, //保底暴击概率值
    BATTLE_RATE_DOUBLE_ADD = 1500,      //暴击后的加成
    BATTLE_RATE_IMMUNE_INJURY_MAX = 800,//免伤上限
};

//战斗录像类型
enum ENUM_BATTLE_VIDEO_TYPE
{
    BATTLE_VIDEO_TYPE_INSTANCE = 1,
    BATTLE_VIDEO_TYPE_ARENA = 2,
    BATTLE_VIDEO_TYPE_CLAN_BATTLE = 3,
    BATTLE_VIDEO_TYPE_ACA_CUP = 4,
};

//游戏通用个体类型 主要包括主角 伙伴 怪物等
enum ENUM_GAME_OBJ_TYPE
{
    GAME_OBJ_TYPE_NULL       = 0,        //空
    GAME_OBJ_TYPE_PLAYER     = 1,        //主角
    GAME_OBJ_TYPE_PARTNER    = 2,        //伙伴
    GAME_OBJ_TYPE_MONSTER    = 3,        //怪物
    GAME_OBJ_TYPE_SERVER_MONSTER_FRONT_ROLE    = 4,        //很特殊的类型 后端是怪物 前端是主角
    GAME_OBJ_TYPE_MOUNT      = 5,        //坐骑
};

//状态来源类型
enum ENUM_STATUS_SOURCE_OBJ_TYPE
{
    STATUS_SOURCE_OBJ_TREASURE      = 1,       //秘宝
    STATUS_SOURCE_OBJ_PLAYER_CFG    = 2,       //主角初始化配置
    STATUS_SOURCE_OBJ_PARTNER_CFG   = 3,       //伙伴初始化配置
    STATUS_SOURCE_OBJ_MONSTER_CFG   = 4,       //怪物初始化配置
    STATUS_SOURCE_OBJ_MOUNT         = 5,       //坐骑
    STATUS_SOURCE_OBJ_MOUNT_SHOW    = 6,       //坐骑出场展示特效
    STATUS_SOURCE_OBJ_ACT_CFG       = 7,       //主角或者伙伴活动获得
};

//武器类型
enum ENUM_WEAPON_TYPE
{
    WEAPON_TYPE_NONE  = 0,   //无效值
    WEAPON_TYPE_BOX   = 1,   //拳套
    WEAPON_TYPE_SWORD = 2,   //剑
    WEAPON_TYPE_BOW   = 3,   //弓
    WEAPON_TYPE_CANE  = 4,   //杖
    WEAPON_TYPE_AXE   = 5,   //斧
};

//聊天类型
enum ENUM_CHAT_TYPE
{
    CHAT_TYPE_NULL = 0,
    CHAT_TYPE_SYSTEM = 1,       //系统公告
    CHAT_TYPE_WORLD = 2,        //世界
    CHAT_TYPE_CLAN = 3,         //家族
    CHAT_TYPE_MAP = 4,          //当前地图
    CHAT_TYPE_HORN = 5,         //喇叭
    CHAT_TYPE_PRIVATE = 6,      //私聊
};

//通知类型
enum NOTIFY_TYPE_TAG
{
    NOTIFY_ROLE_INFO = 1,
    NOTIFY_USER_MONEY = 1 << 1,
    NOTIFY_BAG_INFO = 1 << 2,
    NOTIFY_WARE_INFO = 1 << 3,
    NOTIFY_PARTNER_INFO = 1 << 4,
    NOTIFY_INSTANCE_INFO = 1 << 5,
    NOTIFY_TASK_LIST = 1 << 6,
    NOTIFY_ZONE_INFO = 1 << 7,
    NOTIFY_CARD_POINT = 1 << 8,
    NOTIFY_MUSE_INFO = 1 << 9,
    NOTIFY_PET_INFO = 1 << 10,
    NOTIFY_BONUS_INFO = 1 << 11,
    NOTIFY_SYSOPEN_INFO = 1 << 12,
    NOTIFY_MAP_INFO = 1 << 13,
    NOTIFY_PARTNER_EXP  = 1 << 14, //伙伴经验
    NOTIFY_ROLE_ATTR  = 1 << 15, //重新计算并下发主角二级属性
    NOTIFY_PARTNER_ATTR  = 1 << 16, //重新计算并下发伙伴二级属性
};

//学院类型
enum ENUM_ACADEMY_TYPE
{
    ACADEMY_TYPE_COUNT = 4, //学院数量

    ACADEMY_TYPE_NONE = 0,
    ACADEMY_TYPE_GRAN =  1, //格兰
    ACADEMY_TYPE_SLEN =  2, //斯林
    ACADEMY_TYPE_RAVAN = 3, //拉文
    ACADEMY_TYPE_HUFF  = 4, //霍奇

    //学院合并：格兰和霍奇合并，合并后叫格兰; 拉文和斯林合并，合并后叫斯林
    ACADEMY_TYPE_COUNT_CURRENT = 2, //当前在用学院数量
};

//排行榜
enum ENUM_ZONE_RANK_TYPE
{
    ZONE_RANK_COUNT = 3,  //排行榜数量.

    ZONE_RANK_NONE  = 999999,
    ZONE_RANK_LEVEL = 0,
    ZONE_RANK_FIGHT = 1,
    ZONE_RANK_REPU  = 2,
};

//任务操作类型
enum TASK_DO_STH_OPT
{
    TASK_OPT_ID_100 = 100, //选择性别
    TASK_OPT_ID_101 = 101, //选择武器
    TASK_OPT_ID_102 = 102, //输入游戏昵称
    TASK_OPT_ID_103 = 103, //装备武器
    TASK_OPT_ID_104 = 104, //石头剪子布
    TASK_OPT_ID_105 = 105, //上课
    TASK_OPT_ID_106 = 106, //竞技
    TASK_OPT_ID_107 = 107, //装备秘宝
    TASK_OPT_ID_108 = 108, //和NPC对话
    TASK_OPT_ID_109 = 109, //冥想
    TASK_OPT_ID_110 = 110, //炼金
    TASK_OPT_ID_111 = 111, //占卜
    TASK_OPT_ID_112 = 112, //培养宠物

    TASK_OPT_ID_113 = 113, //将一件任意装备强化到X级
    TASK_OPT_ID_114 = 114, //加入或创建一个家族
    TASK_OPT_ID_115 = 115, //学习一次家族技能
    TASK_OPT_ID_116 = 116, //将伙伴X等级提升至Y级
    TASK_OPT_ID_117 = 117, //开采魔晶
    TASK_OPT_ID_118 = 118, //进行家族转盘
    TASK_OPT_ID_119 = 119, //加入学院
    TASK_OPT_ID_120 = 120, //进入主线副本
    TASK_OPT_ID_121 = 121, //强化装备
    TASK_OPT_ID_122 = 122, //打开宠物面板
    TASK_OPT_ID_123 = 123, //镶嵌魔晶
    TASK_OPT_ID_124 = 124, //伙伴升级
    TASK_OPT_ID_125 = 125, //家族捐献
    TASK_OPT_ID_126 = 126, //家族闯关
    TASK_OPT_ID_127 = 127, //家族浇水
    TASK_OPT_ID_128 = 128, //升级课程
    TASK_OPT_ID_129 = 129, //装备洗练:激活
    TASK_OPT_ID_130 = 130, //提升魔晶潜能
    TASK_OPT_ID_131 = 131, //宠物高级培养
    TASK_OPT_ID_132 = 132, //魂器解封
    TASK_OPT_ID_133 = 133, //集市任务
    TASK_OPT_ID_134 = 134, //坐骑：猎魂
    TASK_OPT_ID_135 = 135, //装备祝福
};

//活动奖励ID
#define  MAX_ACT_PENDING_ITEM    10   //每个活动最多的未领取物品数
#define  ACT_BONUS_TYPE_MAX    30   //

//活动礼包ID
enum ACT_BONUS_TYPE
{
    ACT_BONUS_TYPE_NULL = 0,                //空
    ACT_BONUS_TYPE_AUCTION   = 13,          //拍卖会物品
    ACT_BONUS_TYPE_EXSPACE   = 14,          //背包满后未领取的物品
    ACT_BONUS_TYPE_CLAN       = 15,         //族长分配的奖励
    ACT_BONUS_TYPE_ARENA_RANK = 16,         //竞技场排名奖励礼包ID
    ACT_BONUS_TYPE_CLAN_BATTLE_ROLE = 17,   //家族战个人排行榜礼包ID
    ACT_BONUS_TYPE_CLAN_BATTLE_CLAN = 18,   //家族战家族排行榜礼包ID
};

//活动开关的位.(最多32个)
enum ENUM_ACT_BIT_POS
{
    ACT_BIT_NEWSALES1  = 1,   //开服特卖(活动开启时,置为真. 物品买完时置为假)
    ACT_BIT_NEWSALES2  = 2,   //开服特卖(物品买完时置为真, 领完奖励后置为假)
};

//精彩活动ID
enum SPLENDID_ACT_ID
{
    SPLENDID_ACT_ID_NULL = 0,
    SPLENDID_ACT_ID_1 = 1, //升到40级夺豪礼
    SPLENDID_ACT_ID_2 = 2, //升到50级夺豪礼
    SPLENDID_ACT_ID_3 = 3, //3阶宠物养成大礼
    SPLENDID_ACT_ID_4 = 4, //4阶宠物养成大礼
    SPLENDID_ACT_ID_5 = 5, //5阶宠物养成大礼
    SPLENDID_ACT_ID_6 = 6, //招募湖中仙女
    SPLENDID_ACT_ID_7 = 7, //魔晶合成赢幸运
    SPLENDID_ACT_ID_8 = 8, //全服家族排名活动
    SPLENDID_ACT_ID_9 = 9, //怪物攻城连杀奖励
    SPLENDID_ACT_ID_10 = 10, //充值送魔晶活动
    SPLENDID_ACT_ID_11 = 11, //中秋活动
    SPLENDID_ACT_ID_12 = 12, //消费排行
    SPLENDID_ACT_ID_13 = 13, //国庆登录有奖
    SPLENDID_ACT_ID_14 = 14, //国庆集卡
    SPLENDID_ACT_ID_15 = 15, //金秋猎金
    SPLENDID_ACT_ID_16 = 16, //感恩节砸蛋
    SPLENDID_ACT_ID_17 = 17, //转盘
    SPLENDID_ACT_ID_18 = 18, //双蛋活动
    SPLENDID_ACT_ID_19 = 19, //摇摇乐活动
    SPLENDID_ACT_ID_20 = 20, //领红包活动

    MAX_SPLENDID_ACT_ID = 20,
};

//冷却时间相关
enum COOLING_CONFIG_ID
{
    COOLING_CONFIG_MIN = 1,

    COOLING_CONFIG_1 = 1,   //有求必应屋修炼冷却
    COOLING_CONFIG_2 = 2,   //竞技场冷却
    PET_EXPLORE_COOLID = 3,   //宠物探险冷却
    COOLING_CONFIG_4 = 4,   //上课冷却

    COOLING_CONFIG_MAX = 4,
};

//OSS相关
enum OSS_TRIGGER_TYPE
{
    OSS_TRIGGER_REGISTER    = 1,
    OSS_TRIGGER_NEWDAY      = 2,    //跨天
    OSS_TRIGGER_ACT         = 3,    //活跃
    OSS_TRIGGER_PAY         = 4,    //付费行为
    OSS_TRIGGER_LOGIN       = 5,    //登录
    OSS_TRIGGER_LOGOUT      = 6,    //登出
    OSS_TRIGGER_MONEY       = 7,    //金钱变化
    OSS_TRIGGER_EXIT        = 8,    //mainsvr停机
};

//玩家称号
enum EN_ROLE_TITLE_TYPE
{
    MAX_ROLE_TITLE_CNT  =  11,  //单个用户最多可获得的称号

    ROLE_TITLE_AUCTION = 1,  //拍卖王（拍中压轴物品的玩家获得）
    ROLE_TITLE_ACADMY  = 2,  //学院之星（在学院排行榜上获得任意一项第一后获取）
    ROLE_TITLE_ARENA   = 3,  //竞技之王（竞技场排名第一获取）
    ROLE_TITLE_ENMCITY = 4,  //嗜血守护（怪物攻城排名第一获取）
    ROLE_TITLE_WLDBOSS = 5,  //天空之怒（世界boss排名第一获取）
    ROLE_TITLE_LEVEL   = 6,  //冲级之王（等级排行榜第一获取）
    ROLE_TITLE_REPUT   = 7,  //我是传奇（声望排行榜第一获取）
    ROLE_TITLE_FIGHT   = 8,  //战争之主（战力排行榜第一获取）
    ROLE_TITLE_ACA_CUP_FIRST = 9, //学院杯第一
    ROLE_TITLE_MANOR_DEFEND = 10, //领地战领地护佑者
    ROLE_TITLE_MANOR_ATTACK = 11, //领地战领地破坏者
};

//冻结玩家类型
enum ENUM_ROLE_FREEZE_TYPE
{
    ROLE_FREEZE_LOGIN       = 1,  //冻结玩家登录
    ROLE_FREEZE_GOLD        = 2,  //冻结玩家金币
    ROLE_FREEZE_SILVER      = 3,  //冻结玩家银币
    ROLE_FREEZE_BAG         = 4,  //冻结玩家背包
    ROLE_FREEZE_STORGE      = 5,  //冻结玩家仓库
    ROLE_FREEZE_SPEAK       = 6,  //冻结玩家发言
};

enum VarObjectOpType_tag
{
    VOP_SELECT = 0,
    VOP_CREATE = 1,
    VOP_UPDATE = 2,
    VOP_DELETE = 3,
};

//通知发货的来源
enum EN_DELIVER_GOODS_TYPE
{
    DELIVER_GOODS_OWN = 1,   //游戏内部通知
    DELIVER_GOODS_QQ = 2,    //QQ平台
};

enum VarObjectDataType_tag
{
    DT_SWAPCOUNT = 0,
    DT_PLAYER_BASE_INFO = 1,
    DT_PLAYER_GID = 2,
    DT_MAX_PLAYER_GID = 3,
    DT_PLAYER_DETAIL_INFO = 4,
    DT_PLAYER_SNS_DETAIL_INFO = 5,
    DT_PLAYER_SNS_MY_INFO = 6,
    DT_PLAYER_SNS_COMM_INFO = 7,
    DT_PLAYER_SNS_COMM_INFO_COUNT = 8,
    DT_PLAYER_UNACT_PARTNER = 9,            //未激活的伙伴数据
    DT_ARENA_RANK_COUNT = 10,                    //竞技场记录数量
    DT_ARENA_RANK = 11,                          //竞技场数据
    DT_ZONE_DATA = 12,                       //大区数据
    DT_FLUSH_DBSVR_DATA = 13,                //通知DBSVR将数据刷入数据库，主要用于重启
    DT_CLAN_DATA = 14,                       //家族数据
    DT_CLAN_DATA_COUNT = 15,                 //家族数量
    DT_OSS_PLAYER_DATA = 16,                 //OSS用户数据
    DT_OSS_ZONE_DATA = 17,                   //OSS大区数据
    DT_INSTANCE_ZONE_DETAIL_INFO = 18,       //副本大区详细数据
    DT_OSS_PLAYER_MONEY = 19,                //OSS用户金币\银币操作
    DT_PLAYER_DETAIL_EX1_INFO = 20,
    DT_ZONE_COUNT  = 21,                     //大区记录数，启动时使用
};

typedef CTLib::CTSizeString<MAX_VIDEO_KEY_LEN> T_VIDEO_KEY;

/*
*可变对象的key
*/
class CVarObjectKey : public CTCodeObject
{
public:
    CVarObjectKey()
    {
        OBJ_CHECK_RELOAD();
        m_u64ID = 0;
        m_chDataType = 0;
    }

    CTSizeString<EMAX_STRING_KEY_LEN> m_sStrID;
    uint64 m_u64ID;
    char m_chDataType;  //数据类型

    bool operator== (const CVarObjectKey & stKey) const
    {
        if(m_sStrID == stKey.m_sStrID
            && m_u64ID == stKey.m_u64ID
            && m_chDataType == stKey.m_chDataType)
        {
            return true;
        }
        return false;
    }
};
BEGIN_CODE_CONVERT(CVarObjectKey)
CODE_CONVERT(m_sStrID)
CODE_CONVERT(m_u64ID)
CODE_CONVERT(m_chDataType)
END_CODE_CONVERT(CVarObjectKey)

//////////////////////////////////////////////////////////////////////////

class CGidList : public CTCodeObject
{
public:
    CGidList()
    {
        Clear();
    }

    void Clear()
    {
        _uiNowUseGID = 0;
        _auiGID.Clear();
    }

    unsigned int _uiNowUseGID;      //当前使用的GID，不入库
    CTLib::CTArray<unsigned int, MAX_GID_COUNT_PER_USER> _auiGID;
};
BEGIN_CODE_CONVERT(CGidList)
CODE_CONVERT(_auiGID)
END_CODE_CONVERT(CGidList)

//////////////////////////////////////////////////////////////////////////

//每日自动更新的数据
template<typename T>
class CDailyReflushData : public CTCodeObject
{
public:
    CDailyReflushData()
    {
        Clear ();
    }

    void Clear ()
    {
        _iLastUpdateTime = 0;
        _stDefaultData = 0;
        _stData = 0;
    }

    void SetDefault(T stData)
    {
        _stDefaultData = stData;
    }

    T Get(int iNowTime, int iTimeOffset = DATA_RESET_SEC_OF_DAY)
    {
        if (!CTTimeUtils::IsSameDay(_iLastUpdateTime, iNowTime, iTimeOffset))
        {
            return _stDefaultData;
        }

        return _stData;
    }

    bool IsSameDay(int iNowTime, int iTimeOffset = DATA_RESET_SEC_OF_DAY)
    {
        return CTTimeUtils::IsSameDay(_iLastUpdateTime, iNowTime, iTimeOffset);
    }

    bool IsYesterday(int iNowTime, int iTimeOffset = DATA_RESET_SEC_OF_DAY)
    {
        return CTTimeUtils::IsSameDay(_iLastUpdateTime, iNowTime-86400, iTimeOffset);
    }

    bool IsTimeOut(int iNowTime, int iTimeDiff)
    {
        return (iNowTime - _iLastUpdateTime >= iTimeDiff) ? true : false;
    }

    T GetData()
    {
        return _stData;
    }

    void Add(T stCount, int iNowTime, int iTimeOffset = DATA_RESET_SEC_OF_DAY)
    {
        _stData = Get(iNowTime, iTimeOffset);
        _stData += stCount;
        _iLastUpdateTime = iNowTime;
    }

    void Sub(T stCount, int iNowTime, int iTimeOffset = DATA_RESET_SEC_OF_DAY)
    {
        _stData = Get(iNowTime, iTimeOffset);
        _stData -= stCount;
        _iLastUpdateTime = iNowTime;
    }

    void Set(T stCount, int iNowTime)
    {
        _stData = stCount;
        _iLastUpdateTime = iNowTime;
    }

public:
    T _stDefaultData;       //缺省值，不入库

    int _iLastUpdateTime;
    T _stData;
};

typedef CDailyReflushData<char> CDailyReflushChar;
BEGIN_CODE_CONVERT(CDailyReflushChar)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushChar)

typedef CDailyReflushData<unsigned char> CDailyReflushUChar;
BEGIN_CODE_CONVERT(CDailyReflushUChar)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushUChar)

typedef CDailyReflushData<short> CDailyReflushShort;
BEGIN_CODE_CONVERT(CDailyReflushShort)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushShort)

typedef CDailyReflushData<unsigned short> CDailyReflushUShort;
BEGIN_CODE_CONVERT(CDailyReflushUShort)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushUShort)

typedef CDailyReflushData<int> CDailyReflushInt;
BEGIN_CODE_CONVERT(CDailyReflushInt)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushInt)

typedef CDailyReflushData<unsigned int> CDailyReflushUInt;
BEGIN_CODE_CONVERT(CDailyReflushUInt)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushUInt)

typedef CDailyReflushData<int64> CDailyReflushInt64;
BEGIN_CODE_CONVERT(CDailyReflushInt64)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushInt64)

typedef CDailyReflushData<uint64> CDailyReflushUInt64;
BEGIN_CODE_CONVERT(CDailyReflushUInt64)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushUInt64)

//每月自动更新的数据 当前暂时不支持偏移 以0点为结算
template<typename T>
class CMonthlyReflushData : public CTCodeObject
{
public:
    CMonthlyReflushData()
    {
        Clear ();
    }

    void Clear ()
    {
        _iLastUpdateTime = 0;
        _stDefaultData = 0;
        _stData = 0;
    }

    void SetDefault(T stData)
    {
        _stDefaultData = stData;
    }

    T Get(int iNowTime)
    {
        if (!CTTimeUtils::IsSameMonth(_iLastUpdateTime, iNowTime))
        {
            return _stDefaultData;
        }

        return _stData;
    }

    void Add(T stCount, int iNowTime)
    {
        _stData = Get(iNowTime);
        _stData += stCount;
        _iLastUpdateTime = iNowTime;
    }

    void Sub(T stCount, int iNowTime)
    {
        _stData = Get(iNowTime);
        _stData -= stCount;
        _iLastUpdateTime = iNowTime;
    }

    void Set(T stCount, int iNowTime)
    {
        _stData = stCount;
        _iLastUpdateTime = iNowTime;
    }

public:
    T _stDefaultData;       //缺省值，不入库

    int _iLastUpdateTime;
    T _stData;
};

typedef CMonthlyReflushData<int> CMonthlyReflushInt;
BEGIN_CODE_CONVERT(CMonthlyReflushInt)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CMonthlyReflushInt)

class CDropItemData : public CTCodeObject
{
public:
    CDropItemData()
        :_ucItemType(0), _usItemConfigID(0), _iItemCount(0), _iData1(0)
    {
    }

    void Clear ()
    {
        _ucItemType = 0;
        _usItemConfigID = 0;
        _iItemCount = 0;
        _iData1 = 0;
    }

    bool operator == (const CDropItemData & stItem)
    {
        if (_ucItemType == stItem._ucItemType
            && _usItemConfigID == stItem._usItemConfigID
            && _iItemCount == stItem._iItemCount
            && _iData1 == stItem._iData1)
        {
            return true;
        }

        return false;
    }

    virtual ~CDropItemData()
    {
    }

public:
    unsigned char   _ucItemType;
    unsigned short  _usItemConfigID;
    int             _iItemCount;

    int             _iData1;
};

BEGIN_CODE_CONVERT(CDropItemData)
CODE_CONVERT(_ucItemType)
CODE_CONVERT(_usItemConfigID)
CODE_CONVERT(_iItemCount)
CODE_CONVERT(_iData1)
END_CODE_CONVERT(CDropItemData)

//消息
class CTips : public CTCodeObject
{
public:
    CTips()
    {
        _iType = 0;
        _iData1 = 0;
        _iData2 = 0;
        _iData3 = 0;
        _iData4 = 0;
    }

public:
    int _iType; //见MsgComm.proto中的MsgTips协议描述

    int _iData1;
    int _iData2;
    int _iData3;
    int _iData4;
};
BEGIN_CODE_CONVERT(CTips)
CODE_CONVERT(_iType)
CODE_CONVERT(_iData1)
CODE_CONVERT(_iData2)
CODE_CONVERT(_iData3)
CODE_CONVERT(_iData4)
END_CODE_CONVERT(CTips)

class COfflineTips : public CTCodeObject
{
public:
    COfflineTips()
    {
        Clear();
    }

    void Clear()
    {
        _astTips.Clear();
    }

    void AddTips(CTips& stTips)
    {
        if (_astTips.Size() >= _astTips.GetCount())
        {
            _astTips.ShiftDelOneItem(0);
        }

        _astTips.AddOneItem(stTips);
    }

public:
    CTLib::CTArray<CTips, MAX_OFFLINE_TIPS_COUNT> _astTips; //消息是按照时间倒序排的
};
BEGIN_CODE_CONVERT(COfflineTips)
CODE_CONVERT(_astTips)
END_CODE_CONVERT(COfflineTips)

//离线物品
class COfflineItems : public CTCodeObject
{
public:
    COfflineItems()
    {

    }

    void AddItem()
    {

    }

public:
    CTLib::CTArray<CDropItemData, MAX_OFFLINE_ITEM_COUNT> _astItems;
};
BEGIN_CODE_CONVERT(COfflineItems)
CODE_CONVERT(_astItems)
END_CODE_CONVERT(COfflineItems)

//任务相关结构
class CTaskCondData : public CTCodeObject
{
public:
    CTaskCondData()
    {
        _ucCond = 0;
        _iCondData1 = 0;
        _iCondData2 = 0;
        _iInstanceMapId = 0;
    }

    unsigned char _ucCond;          //类型
    int _iCondData1;                //条件数值1，辅助_ucOpenCond
    int _iCondData2;                //条件数值2，辅助_ucOpenCond
    int _iInstanceMapId;            //instance id for item id
};
BEGIN_CODE_CONVERT(CTaskCondData)
CODE_CONVERT(_ucCond)
CODE_CONVERT(_iCondData1)
CODE_CONVERT(_iCondData2)
END_CODE_CONVERT(CTaskCondData)

class CTaskIDData : public CTCodeObject
{
public:
    CTaskIDData()
    {
        _uiBranchID = 0;
        _uiTaskID = 0;
    }

    unsigned int _uiBranchID;       //从0开始，最大值为MAX_BRANCH_TASK_CONFIG - 1
    unsigned int _uiTaskID;         //从0开始，最大值为MAX_MAIN_TASK_CONFIG - 1
};
BEGIN_CODE_CONVERT(CTaskIDData)
CODE_CONVERT(_uiBranchID)
CODE_CONVERT(_uiTaskID)
END_CODE_CONVERT(CTaskIDData)

class CTaskTargetStatData : public CTCodeObject
{
public:
    CTaskTargetStatData()
    {
        _ucIsReachCond = 0;
        _iData1 = 0;
    }

    unsigned char   _ucIsReachCond;
    CTaskIDData         _stTaskID;
    CTaskCondData       _stCond;
    CTaskCondData       _stNowStat;

    int _iData1;        //额外数据
};

BEGIN_CODE_CONVERT(CTaskTargetStatData)
CODE_CONVERT(_ucIsReachCond)
CODE_CONVERT(_stTaskID)
CODE_CONVERT(_stCond)
CODE_CONVERT(_stNowStat)
CODE_CONVERT(_iData1)
END_CODE_CONVERT(CTaskTargetStatData)

class CValidTaskData : public CTCodeObject
{
public:
    CValidTaskData()
    {
        _ucIsFinished = 0;
        _astTargetStats.Clear();
        _iTaskEndTime = 0;
    }

    unsigned char _ucIsFinished;
    CTaskIDData _stTaskID;
    CTLib::CTArray<CTaskTargetStatData, MAX_TASK_FINISH_COND>   _astTargetStats;

    int _iTaskEndTime;           //任务到期时间
    unsigned int _uiPublishGID;  //发布者的GID(悬赏令任务用)
};

BEGIN_CODE_CONVERT(CValidTaskData)
CODE_CONVERT(_ucIsFinished)
CODE_CONVERT(_stTaskID)
CODE_CONVERT(_astTargetStats)
CODE_CONVERT(_iTaskEndTime)
CODE_CONVERT(_uiPublishGID)
END_CODE_CONVERT(CValidTaskData)

class CTaskWaitForOpenData : public CTCodeObject
{
public:
    CTaskWaitForOpenData()
    {
        _astTargetStats.Clear();
        _ucIsDirectAccept = true;
    }

    CTaskIDData   _stTaskID;
    CTLib::CTArray<CTaskTargetStatData, MAX_TASK_FINISH_COND>   _astTargetStats;
    unsigned char _ucIsDirectAccept;
};

BEGIN_CODE_CONVERT(CTaskWaitForOpenData)
CODE_CONVERT(_stTaskID)
CODE_CONVERT(_astTargetStats)
CODE_CONVERT(_ucIsDirectAccept)
END_CODE_CONVERT(CTaskWaitForOpenData)

class CTaskStatusData : public CTCodeObject
{
public:
    CTaskStatusData()
    {
        _uiMainTaskStatus = 0;
        _astBranchTaskStatus.Clear();
    }

    int Clear()
    {
        _uiMainTaskStatus = 0;
        _astBranchTaskStatus.Clear();

        return 0;
    }

    unsigned int                                    _uiMainTaskStatus;         //主线任务历史
    CTLib::CTArray<unsigned char, MAX_TASK_BRANCHS> _astBranchTaskStatus;      //分支任务历史
};

BEGIN_CODE_CONVERT(CTaskStatusData)
CODE_CONVERT(_uiMainTaskStatus)
CODE_CONVERT(_astBranchTaskStatus)
END_CODE_CONVERT(CTaskStatusData)

class CUserTaskData : public CTCodeObject
{
public:
    CUserTaskData()
    {

    }

    int Clear()
    {
        _stTaskStatus.Clear();
        _astOpenTaskIDs.Clear();
        _astValidTasks.Clear();
        _astWaitForOpenTasks.Clear();

        return 0;
    }

    CTaskStatusData                                                 _stTaskStatus;
    CTLib::CTArray<CTaskIDData, MAX_OPEN_TASK>                      _astOpenTaskIDs;            //已经激活的任务
    CTLib::CTArray<CValidTaskData, MAX_VALID_TASK>                  _astValidTasks;             //进行中的任务
    CTLib::CTArray<CTaskWaitForOpenData, MAX_WAIT_FOR_OPEN_TASK>    _astWaitForOpenTasks;       //等待激活的任务
};

BEGIN_CODE_CONVERT(CUserTaskData)
CODE_CONVERT(_stTaskStatus)
CODE_CONVERT(_astOpenTaskIDs)
CODE_CONVERT(_astValidTasks)
CODE_CONVERT(_astWaitForOpenTasks)
END_CODE_CONVERT(CUserTaskData)


class CVipData:public CTCodeObject
{
public:
    CVipData()
    {
        _ucCanGetFirstPayBonus = 0;
        _iPayGold = 0;          //累计充值金币
        _bHasInit = 0;
        Clear();
    }

    //int _iVipLevel;      //vip等级保存在base里面
    CDailyReflushShort  _sVipDailyAward; //vip每日礼包
    short _bHasInit;      //是否初始化过礼包
    CTLib::CTArray<short, MAX_VIP_LEVEL> _aVipLevelGift; //等级礼包领取状态, 0:不可领取，1：已经领取，2:尚未领取
    int _iPayGold;          //累计充值金币
    unsigned char _ucCanGetFirstPayBonus; //是否可领取首充奖励

public:
    void Clear()
    {
        //_iVipLevel = 0;
        _sVipDailyAward.SetDefault(1); //每日一次
        _aVipLevelGift.Clear();
    }
};

BEGIN_CODE_CONVERT(CVipData)
CODE_CONVERT(_sVipDailyAward)
CODE_CONVERT(_aVipLevelGift)
CODE_CONVERT(_bHasInit)
CODE_CONVERT(_iPayGold)
CODE_CONVERT(_ucCanGetFirstPayBonus)
END_CODE_CONVERT(CVipData);

class CPetData:public CTCodeObject
{
public:
    CPetData()
    {
        Clear();
    }

public:
    int _iPetStyle;      //宠物形态
    int _iPetLevel;      //宠物等阶
    int _iPetStar;       //宠物星级
    int _iPetExper;      //当前星级经验
    //int _iCurTime;       //记录当日探险起始时间
    int _iNextCDTime;       //下次探险cd时间
    //int _iExploreCountInDay; //当日剩余探险次数,默认为最多次数
    CDailyReflushShort  _sExploreCountInDay; //当日剩余探险次数,默认为最多次数
    int _iPetFruit;      //吃了多少个果实
    int _iDailyCritNums;    //每天前三次暴击剩余次数，初始为最大值3
    CTLib::CTSizeString<PETNAME_LEN> _sPetName;  //宠物昵称
    CTLib::CTArray<int, MAX_PET_EXPLORE_NUM> _aPetExploreEventList; //每日探险事件列表
    short _iIsActive;           //宠物是否激活, 默认没有, 1,激活
    short _iIsRecvFruit;  //是否领取宠物果实, 0:没有果实领取， 1：有果实奖励但没领取, 2:有果实奖励已领取
    CTLib::CTArray<short, MAX_PET_AWARD_FRUIT_NUM> _aPetAwardFruits; //升星级奖励给用户的果实
    int _iPetMaxCanUseStyle;    //最大可使用宠物形态

public:
    void Clear()
    {
        _iPetStyle = 0;
        _iPetLevel = 0;
        _iPetStar  = 0;
        _iPetExper = 0;
        //_iCurTime  = 0;
        _iNextCDTime = 0;
        //_iExploreCountInDay = 0;
        _sExploreCountInDay.SetDefault(MAX_PET_EXPLORE_NUM); //当日剩余探险次数,默认为最多次数
        _iPetFruit   = 0;
        _sPetName.Set("");
        _aPetExploreEventList.Clear();
        _aPetAwardFruits.Clear();
        _iIsActive = 0;
        _iIsRecvFruit = 0;
        _iPetMaxCanUseStyle = PET_STATUS_TYPE_OWL;
    }
};

BEGIN_CODE_CONVERT(CPetData)
CODE_CONVERT(_iPetStyle )
CODE_CONVERT(_iPetLevel )
CODE_CONVERT(_iPetStar  )
CODE_CONVERT(_iPetExper )
CODE_CONVERT(_iNextCDTime)
CODE_CONVERT(_sExploreCountInDay )
CODE_CONVERT(_iPetFruit )
CODE_CONVERT(_iDailyCritNums)
CODE_CONVERT(_sPetName  )
CODE_CONVERT(_aPetExploreEventList)
CODE_CONVERT(_iIsActive)
CODE_CONVERT(_iIsRecvFruit)
CODE_CONVERT(_aPetAwardFruits)
CODE_CONVERT(_iPetMaxCanUseStyle)
END_CODE_CONVERT(CPetData)

//日常任务相关
class CDTaskStatus:public CTCodeObject
{
public:
    CDTaskStatus()
    {
        Clear();
    }

    void Clear()
    {
        iTaskId = 0;
        iCount = 0;
        _iTaskClassTypeId = 0;
        _stYesterdayTaskFinish.SetDefault(0);
        _iFindYesterdayOp = 0;
    }

public:
    short iTaskId; //任务id
    short iCount; //完成次数
    short _iTaskClassTypeId; //任务类型
    CDailyReflushShort  _stYesterdayTaskFinish;     //记录此任务昨日的完成次数
    short _iFindYesterdayOp;        //0:今天没有做过找回操作, >0:今天做找回操作时的已经完成次数
};

BEGIN_CODE_CONVERT(CDTaskStatus)
CODE_CONVERT(iTaskId)
CODE_CONVERT(iCount)
CODE_CONVERT(_iTaskClassTypeId)
CODE_CONVERT(_stYesterdayTaskFinish)
CODE_CONVERT(_iFindYesterdayOp)
END_CODE_CONVERT(CDTaskStatus)

class CSecretaryData:public CTCodeObject
{
public:
    char _cStyle; //小秘书形象
    short _iLevel; //小秘书等级
    int _iIntimacy; //小秘书亲密度
    int _iLiveTime; //小秘书有效期, 30天，0表示无限期

public:
    void Clear()
    {
        _cStyle = 0;
        _iLevel = 0;
        _iIntimacy = 0;
        _iLiveTime = 0;
    }
};
BEGIN_CODE_CONVERT(CSecretaryData)
CODE_CONVERT(_cStyle)
CODE_CONVERT(_iLevel)
CODE_CONVERT(_iIntimacy)
CODE_CONVERT(_iLiveTime)
END_CODE_CONVERT(CSecretaryData)

//存放在base数据里面，需要入库
class CDailyTaskUserData:public CTCodeObject
{
public:
    CDailyTaskUserData()
    {
        Clear();
    }

public:
    int _iLiveValuer;            //活跃度
    CTArray<short, MAX_TBOX_NUM> _aOpenedTBox; //记录已经开启的宝箱id, 0:当前不可开启, 1:可开启, 2:已经开启
    CTArray<short, MAX_DAILY_TASK_CLASS_CONFIG> _aTaskClassStatus; //key:任务类型,value:是否已经给予类型完成奖励,0:没有,1:已经给于类型奖励
    CTArray<CDTaskStatus, MAX_DAILY_TASK_CONFIG> _aDailyTaskUserClass;//用户每日任务所有任务记录

    CDailyReflushShort  _stDailyLivess;     //每日小秘书活跃度领取标志，同时可做是否同一天记录
    CSecretaryData   _stSecretary;          //小秘书数据

public:
    void Clear()
    {
        this->_aDailyTaskUserClass.Clear();
        this->_aOpenedTBox.Clear();
        this->_aTaskClassStatus.Clear();
        this->_iLiveValuer = 0;
        this->_stDailyLivess.SetDefault(1);
        this->_stSecretary.Clear();
    }
};

BEGIN_CODE_CONVERT(CDailyTaskUserData)
CODE_CONVERT(_iLiveValuer)
CODE_CONVERT(_aOpenedTBox)
CODE_CONVERT(_aTaskClassStatus)
CODE_CONVERT(_aDailyTaskUserClass)
CODE_CONVERT(_stDailyLivess)
CODE_CONVERT(_stSecretary)
END_CODE_CONVERT(CDailyTaskUserData)

class CAuctionRecord: public CTCodeObject
{
public:
    CAuctionRecord ()
    {
        Clear();
    }

    void Clear ()
    {
        _usGoodId = 0;
        _iTime = 0;
        _iSilver = 0;
        _uiSilverGID = 0;
        _iGold = 0;
        _uiGoldGID = 0;
        _uiData = 0;
    }

    bool HasRoundResult ()  //是否已经结算
    {
        return (0 != _iTime);
    }

    int EndTime ()  //拍卖结算时间
    {
        return (int)(_uiData);
    }

    unsigned short _usGoodId;
    int _iTime;     //发货时间,防止服务器异常时,未发货的情况
    int _iSilver;
    unsigned int   _uiSilverGID;
    int _iGold;
    unsigned int   _uiGoldGID;

    unsigned int   _uiData;
};
BEGIN_CODE_CONVERT(CAuctionRecord)
CODE_CONVERT(_usGoodId)
CODE_CONVERT(_iTime)
CODE_CONVERT(_iSilver)
CODE_CONVERT(_uiSilverGID)
CODE_CONVERT(_iGold)
CODE_CONVERT(_uiGoldGID)
CODE_CONVERT(_uiData)
END_CODE_CONVERT(CAuctionRecord)

#define MAX_AUCTION_PENDING_GOODS   10  //用户最多未领取拍卖品
class CAuctionUserData:public CTCodeObject
{
public:
    CAuctionUserData ()
    {
        Clear();
    }

    void Clear()
    {
        _iBlindTime = 0;
        _iBlindSilver = 0;
        _iBlindGold = 0;
    }

    int _iBlindTime;   //暗拍出价时间. (暗拍未成功的话,返款后,时间置0)
    int _iBlindSilver; //暗拍出价银币
    int _iBlindGold;   //暗拍出价金币
    CTArray<unsigned short, MAX_AUCTION_PENDING_GOODS> _astPending;  //用户最多未领取的拍卖品
};

BEGIN_CODE_CONVERT(CAuctionUserData)
CODE_CONVERT(_iBlindTime)
CODE_CONVERT(_iBlindSilver)
CODE_CONVERT(_iBlindGold)
CODE_CONVERT(_astPending)
END_CODE_CONVERT(CAuctionUserData)


enum EN_AUCTION_TYPE
{
    AUCTION_TYPE_MIN  = 1,
    AUCTION_TYPE_MAX  = 3,

    AUCTION_TYPE_BLIND          = 1,  //暗拍
    AUCTION_TYPE_PUBLIC         = 2,  //竞拍
    AUCTION_TYPE_FINAL          = 3,  //压轴

    AUCTION_PUBLIC_LIVE         = 4,  //竞价实况(前台展示用)
    AUCTION_FINAL_NOTICE        = 5,  //压轴开启前三分钟跑马灯(前台展示用)
    AUCTION_PUBLIC_WILL_END     = 6,  //竞拍结束前5分钟增加一条跑马灯(前台展示用)    
};

class CAuctionHistory: public CTCodeObject
{
public:
    CAuctionHistory ()
    {
        Clear();
    }

    void Clear ()
    {
        _stPublic.Clear();
        _stBlind.Clear();
    }

    static bool IsValidRound (EN_AUCTION_TYPE enAuctionType, int iRound)
    {
        if (AUCTION_TYPE_PUBLIC == enAuctionType)
        {
            if (iRound <= 0 || iRound > MAX_AUCTION_PUBLIC_ROUNDS)
            {
                return false;
            }
        }

        return true;
    }


    bool HasSameGoods (EN_AUCTION_TYPE enAuctionType, unsigned short usGoodsId)
    {
        for (int i = 0; i < _stPublic.Size(); ++i)
        {
            if (usGoodsId == _stPublic[i]._usGoodId)
            {
                return true;
            }
        }

        return false;
    }

    CAuctionRecord & GetRecord (EN_AUCTION_TYPE enAuctionType, int iRound)
    {
        if (AUCTION_TYPE_PUBLIC == enAuctionType)
        {
            return (0 == iRound) ? GetFinalRecord () : _stPublic[iRound -1];  //第0轮是压轴拍卖的轮次
        }
        else
        {
            return _stBlind;
        }
    }

    CAuctionRecord & GetFinalRecord ()   //获取压轴竞拍记录
    {
        return _stPublic[MAX_AUCTION_PUBLIC_ROUNDS -1];
    }

    int AddRecord (EN_AUCTION_TYPE enAuctionType, CAuctionRecord & stRecord)
    {
        if (AUCTION_TYPE_PUBLIC == enAuctionType)
        {
            _stPublic.AddOneItem(stRecord);
        }
        else
        {
            _stBlind = stRecord;
        }

        return 0;
    }

    CTArray<CAuctionRecord, MAX_AUCTION_PUBLIC_ROUNDS> _stPublic;   //竞价
    CAuctionRecord  _stBlind;    //暗拍(每天就一轮)
};
BEGIN_CODE_CONVERT(CAuctionHistory)
CODE_CONVERT(_stPublic)
CODE_CONVERT(_stBlind)
END_CODE_CONVERT(CAuctionHistory)

//拍卖活动公共数据
class CAuctionCommonData: public CTCodeObject
{
public:
    CAuctionCommonData()
    {
        Clear();
    }

    void Clear()
    {
        _uiKingGid = 0;
        _iLastRefreshTime = 0;
        _iLastResultTime = 0;
        _stTodayHis.Clear();
        _stYestodayHis.Clear();
        _stRollMsg.Clear();
    }

    void SwapHistory ()
    {
        _stYestodayHis.Clear();
        for (int i = 0; i < _stTodayHis._stPublic.Size(); i++)
        {
            _stYestodayHis._stPublic.AddOneItem(_stTodayHis._stPublic[i]);
        }

        _stYestodayHis._stBlind = _stTodayHis._stBlind;
        _stTodayHis.Clear();
    }

public:
    unsigned int _uiKingGid;            //当前的压轴竞拍竞价王

    //暗拍的数据不入库,用户出价记录在个人身上

    int _iLastRefreshTime;     //上次更新拍卖物品的时间
    int _iLastResultTime;     //今天计算拍卖结果时间

    CAuctionHistory   _stTodayHis;      //今天的拍卖结果
    CAuctionHistory   _stYestodayHis;   //昨日拍卖结果

    CTArray<CAuctionRecord, MAX_AUCTION_ROLL_MSG> _stRollMsg;  //场景出价记录
};
BEGIN_CODE_CONVERT(CAuctionCommonData)
CODE_CONVERT(_uiKingGid)
CODE_CONVERT(_iLastRefreshTime)
CODE_CONVERT(_iLastResultTime)
CODE_CONVERT(_stTodayHis)
CODE_CONVERT(_stYestodayHis)
CODE_CONVERT(_stRollMsg)
END_CODE_CONVERT(CAuctionCommonData)

//许愿池用户数据
class CWishData: public CTCodeObject
{
public:
    CWishData()
    {
        Clear();
    }

    void Clear()
    {
        _astWishList.Clear();
    }

public:
    CTLib::CTArray<int, CONST_WISH_NUM> _astWishList;    //许愿信息
};
BEGIN_CODE_CONVERT(CWishData)
CODE_CONVERT(_astWishList)
END_CODE_CONVERT(CWishData)

//////////////////////////////////////////////////////////////////////////
class CKeyValue : public CTCodeObject
{
public:
    CKeyValue()
    {
        _uiKey = 0;
        _iValue = 0;
    }

    unsigned int    _uiKey;
    int             _iValue;
};

BEGIN_CODE_CONVERT(CKeyValue)
CODE_CONVERT(_uiKey)
CODE_CONVERT(_iValue)
END_CODE_CONVERT(CKeyValue)

//////////////////////////////////////////////////////////////////////////
//基础属性、二级属性相关
enum OBJ_ATTR_TYPE
{
    BASE_ATTR_MIN       = 1,        //基础属性最小值
    BASE_ATTR_MAX       = 4,        //基础属性最大值

    EXT_ATTR_MIM        = 6,
    EXT_ATTR_MAX        = 29,   //二级属性最大值
    //可以等于但不能大于(EXT_ATTR_MAX_COUNT - 1)
    //且必须大于当前在用的

    BASE_ATTR_INT           = 1,        //智力
    BASE_ATTR_VIT           = 2,        //体力
    BASE_ATTR_STR           = 3,        //力量
    BASE_ATTR_AGI           = 4,        //敏捷

    EXT_ATTR_HP                 = 6,        //生命
    EXT_ATTR_PHY_ATK            = 7,        //物攻
    EXT_ATTR_PHY_DEF            = 8,        //物防
    EXT_ATTR_MAG_ATK            = 9,        //魔攻
    EXT_ATTR_MAG_DEF            = 10,       //魔防
    EXT_ATTR_EARTH_ATK          = 11,       //地攻
    EXT_ATTR_WIND_ATK           = 12,       //风攻
    EXT_ATTR_FIRE_ATK           = 13,       //火攻
    EXT_ATTR_WATER_ATK          = 14,       //水攻
    EXT_ATTR_HIT                = 15,       //命中
    EXT_ATTR_DODGE              = 16,       //闪避
    EXT_ATTR_DOUBLE             = 17,       //暴击
    EXT_ATTR_ANTI_DOUBLE        = 18,       //抗暴
    EXT_ATTR_BLOCK              = 19,       //格挡
    EXT_ATTR_ANTI_BLOCK         = 20,       //破击
    EXT_ATTR_TURN_ORDRE         = 21,       //先攻
    EXT_ATTR_CRIT               = 22,       //必杀
    EXT_ATTR_IMMUNE_INJURY      = 23,       //免伤
    EXT_ATTR_REACT_INJURY       = 24,       //反伤
    EXT_ATTR_PENETRATE          = 25,       //穿透
    EXT_ATTR_TREATMENT          = 26,       //痊愈
    EXT_ATTR_FIGHT_BACK         = 27,       //反击
    EXT_ATTR_ACT_ANGER          = 28,       //出场怒气

    EXT_ATTR_MAX_COUNT  = 36,
};

class CAttrPair : public CTCodeObject
{
public:
    CAttrPair()
    {
        _ucType = 0;
        _iValue = 0;
    }

    unsigned char  _ucType;
    int            _iValue;
};

BEGIN_CODE_CONVERT(CAttrPair)
CODE_CONVERT(_ucType)
CODE_CONVERT(_iValue)
END_CODE_CONVERT(CAttrPair)

class CPlayerAttr : public CTCodeObject
{
public:
    typedef CTLib::CTArray<CAttrPair, EXT_ATTR_MAX> T_ATTR_DATAS;

    CPlayerAttr()
    {
        Clear();
    }

    void Clear()
    {
        _aiAttr.m_iUsedCount = _aiAttr.GetCount();
        for (int i = 0; i < _aiAttr.Size(); ++i)
        {
            _aiAttr[i] = 0;
        }
    }

    static bool IsValidAttrType(int iType)
    {
        return (iType >= EXT_ATTR_MIM && iType <= EXT_ATTR_MAX);
    }

    bool IsValidAttrValue()
    {
        for (int i = 0; i < _aiAttr.Size(); ++i)
        {
            if (_aiAttr[i] < 0)
            {
                return false;
            }
        }

        return true;
    }

    CPlayerAttr& operator+=(const CPlayerAttr& stPlayerAttr)
    {
        for (int i = 0 ; i < _aiAttr.Size(); ++i)
        {
            _aiAttr[i] += stPlayerAttr._aiAttr[i];
        }

        return *this;
    }

    CPlayerAttr& operator* (const int iAddtion)
    {
        for (int i = 0 ; i < _aiAttr.Size(); ++i)
        {
            int iAdd = (_aiAttr[i] * iAddtion) / COMM_MOD;
            _aiAttr[i] += iAdd;
        }
        return *this;
    }

    int AddAttr(unsigned char ucType, int iValue)
    {
        if (ucType < BASE_ATTR_MIN || (ucType > BASE_ATTR_MAX && ucType < EXT_ATTR_MIM)
            || ucType > EXT_ATTR_MAX)
        {
            return 0;
        }

        _aiAttr[ucType] += iValue;
        return 0;
    }

    int SetAttr(unsigned char ucType, int iValue)
    {
        if (ucType < BASE_ATTR_MIN || (ucType > BASE_ATTR_MAX && ucType < EXT_ATTR_MIM)
            || ucType > EXT_ATTR_MAX)
        {
            CT_WARNING((""));
            return 0;
        }

        _aiAttr[ucType] = iValue;
        return 0;
    }

    int GetAttr(unsigned char ucType, int& iValue)
    {
        iValue = 0;
        if (ucType < BASE_ATTR_MIN || (ucType > BASE_ATTR_MAX && ucType < EXT_ATTR_MIM)
            || ucType > EXT_ATTR_MAX)
        {
            CT_WARNING((""));
            return 0;
        }

        iValue = _aiAttr[ucType];
        return 0;
    }

    int GetAttr(unsigned char ucType)
    {
        if (ucType < BASE_ATTR_MIN || (ucType > BASE_ATTR_MAX && ucType < EXT_ATTR_MIM)
            || ucType > EXT_ATTR_MAX)
        {
            CT_WARNING((""));
            return 0;
        }

        return _aiAttr[ucType];
    }

    void GetAttr(T_ATTR_DATAS& astAttrData)
    {
        astAttrData.Clear();
        for (unsigned char i = 0; i < _aiAttr.Size(); ++i)
        {
            if (_aiAttr[i] == 0)
            {
                continue;
            }

            CAttrPair stAttrPair;
            stAttrPair._ucType = (i);
            stAttrPair._iValue = _aiAttr[i];
            astAttrData.AddOneItem(stAttrPair);
        }
    }

    bool HasSameAttr(CPlayerAttr& stAttr)
    {
        return GetPosToken() & stAttr.GetPosToken();
    }

    bool IsSameAttr(CPlayerAttr& stAttr)
    {
        return GetPosToken() == stAttr.GetPosToken();
    }

    static bool IsBaseAttr (unsigned char ucType)
    {
        if (BASE_ATTR_INT == ucType
            || BASE_ATTR_VIT == ucType
            || BASE_ATTR_STR == ucType
            || BASE_ATTR_AGI == ucType )
        {
            return true;
        }

        return false;
    }

    uint64 GetPosToken()
    {
        uint64 u64Tmp = 0;
        for (int i = 0; i < _aiAttr.Size(); ++i)
        {
            if (_aiAttr[i] != 0)
            {
                u64Tmp |= ((uint64)1 << i);
            }
        }

        return u64Tmp;
    }

public:
    CTLib::CTArray<int, EXT_ATTR_MAX_COUNT> _aiAttr;
};
BEGIN_CODE_CONVERT(CPlayerAttr)
CODE_CONVERT(_aiAttr)
END_CODE_CONVERT(CPlayerAttr)

//////////////////////////////////////////////////////////////////////////
//博物馆副本排行榜数据
class CInstanceMuseumRankData : public CTCodeObject
{
public:
    CInstanceMuseumRankData()
    {

    }

    //获取排名权值
    uint64 GetRankValue()
    {
        return CT_UINT64_MAKE((_usMaxInstanceID * 20 + _ucMaxEnemyPos), 0);
    }

public:
    unsigned int _uiGID;
    unsigned short _usMaxInstanceID; //最大层数
    unsigned char _ucMaxEnemyPos;   //打到最大层数的第几个怪
    int _iAtkCount;                 //击毁的雕像数量
};
BEGIN_CODE_CONVERT(CInstanceMuseumRankData)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_usMaxInstanceID)
CODE_CONVERT(_ucMaxEnemyPos)
CODE_CONVERT(_iAtkCount)
END_CODE_CONVERT(CInstanceMuseumRankData)

//博物馆系统数据
class CMuseumZoneData : public CTCodeObject
{
public:
    CMuseumZoneData()
    {

    }

public:
    CTLib::CTArray<CInstanceMuseumRankData, MAX_INSTANCE_MUSEUM_RANK_LEN> _astRankDatas;
};

class CInstanceDetailStatData : public CTCodeObject
{
public:
    CInstanceDetailStatData()
    {
        ucNowAccomplishPos = 0;
    }

    unsigned char ucNowAccomplishPos;  //目前征服了当前副本的第几堆怪
    //unsigned char ucMaxAccomplishPos;  //最大征服到第几堆怪
};
BEGIN_CODE_CONVERT(CInstanceDetailStatData)
CODE_CONVERT(ucNowAccomplishPos)
//CODE_CONVERT(ucMaxAccomplishPos)
END_CODE_CONVERT(CInstanceDetailStatData)

class CInstanceStatData : public CTCodeObject
{
public:
    CInstanceStatData()
    {
        Clear();
    }

    void Clear()
    {
        _usMainInstanceData = 0;
        _usChallengeInstanceData = 0;
        _aucBranchInstances.Clear();
    }

    unsigned short _usMainInstanceData;                                         //主线副本
    unsigned short _usChallengeInstanceData;                                    //挑战副本

    CTArray<unsigned char, MAX_INSTANCE_BRANCH_COUNT> _aucBranchInstances;         //分支副本
};

BEGIN_CODE_CONVERT(CInstanceStatData)
CODE_CONVERT(_usMainInstanceData)
CODE_CONVERT(_usChallengeInstanceData)
CODE_CONVERT(_aucBranchInstances)
END_CODE_CONVERT(CInstanceStatData)

//副本分数
class CInstanceScore
{
public:
    CInstanceScore()
    {
        Clear();
    }

    void Clear()
    {
        _bIsInited = false;
        _ucAtkScore = 0;
        _ucDefScore = 0;
    }

    unsigned char GetScore() const
    {
        return _ucAtkScore + _ucDefScore;
    }

    unsigned char GetAtkGrade() const
    {
        return GetDetailGrade(_ucAtkScore);
    }

    unsigned char GetDefGrade() const
    {
        return GetDetailGrade(_ucDefScore);
    }

    unsigned char GetDetailGrade(unsigned char ucScore) const
    {
        if (ucScore >= 45)
        {
            return 5;
        }
        else if (ucScore >= 40)
        {
            return 4;
        }
        else if (ucScore >= 30)
        {
            return 3;
        }
        else if (ucScore >= 15)
        {
            return 2;
        }

        return 1;
    }

    unsigned char GetGrade() const
    {
        unsigned char _ucTotal = GetScore();

        if (_ucTotal >= 90)
        {
            return 5;
        }
        else if (_ucTotal >= 75)
        {
            return 4;
        }
        else if (_ucTotal >= 60)
        {
            return 3;
        }
        else if (_ucTotal >= 21)
        {
            return 2;
        }

        return 1;
    }

    CInstanceScore& operator+=(const CInstanceScore& stScore)
    {
        if (!_bIsInited)
        {
            _ucAtkScore = stScore._ucAtkScore;
            _ucDefScore = stScore._ucDefScore;
            _bIsInited = true;
        }
        else
        {
            _ucAtkScore = (stScore._ucAtkScore + _ucAtkScore) / 2;
            _ucDefScore = (stScore._ucDefScore + _ucDefScore) / 2;
        }

        return *this;
    }

public:
    bool _bIsInited;
    unsigned char _ucAtkScore;  //攻击评分
    unsigned char _ucDefScore;  //防御评分
};

//副本评分
template<int COUNT>
class CInstanceGrade : public CTCodeObject
{
public:
    typedef uint64 T_INS_GRAD_DATA;

    enum INSTANCE_GRAD
    {
        BITS_PER_GRAD = 3,      //每个分数所占比特位数

        INSTANCE_GRAD_MIN = 0,
        INSTANCE_GRAD_MAX = 5,
    };

    CInstanceGrade()
    {
        Clear();
    }

    void Clear()
    {
        _astGradeDatas.Clear();
    }

    //每个T_INS_GRAD_DATA可存放的分数数量
    int GetGradCountPerData() const
    {
        return (sizeof(T_INS_GRAD_DATA) * 8 / BITS_PER_GRAD);
    }

    //最大可支持的副本ID
    int GetMaxInstance() const
    {
        return (GetGradCountPerData() * COUNT);
    }

    int SetGrad(unsigned short usInstanceID, unsigned char ucGrade)
    {
        int iRet = 0;

        if (ucGrade == 0)
        {
            return 0;
        }

        //只保留评分最高的
        unsigned char ucOrgGrade = 0;
        iRet = GetGrad(usInstanceID, ucOrgGrade);
        CHECK_RETURN(iRet);
        if (ucOrgGrade >= ucGrade)
        {
            return 0;
        }

        if (usInstanceID <= 0 || usInstanceID > GetMaxInstance())
        {
            CT_ERROR(("%d", usInstanceID));
            return RET_SYS_ERROR;
        }

        if (ucGrade > INSTANCE_GRAD_MAX)
        {
            CT_ERROR(("%d", ucGrade));
            return RET_SYS_ERROR;
        }

        int iIndex = (usInstanceID - 1) / GetGradCountPerData();
        while (iIndex >= _astGradeDatas.Size())
        {
            _astGradeDatas.AddOneItem(0);
        }

        unsigned char ucMask = 0;
        for (int i = 0; i < BITS_PER_GRAD; ++i)
        {
            ucMask |= (1 << i);
        }

        int iMoveCount = ((usInstanceID - 1) % GetGradCountPerData() * BITS_PER_GRAD);
        T_INS_GRAD_DATA stMaskData = ~((T_INS_GRAD_DATA)ucMask << iMoveCount);
        _astGradeDatas[iIndex] &= stMaskData;
        _astGradeDatas[iIndex] |= (T_INS_GRAD_DATA)ucGrade << iMoveCount;

        return 0;
    }

    int GetGrad(unsigned short usInstanceID, unsigned char& ucGrade)
    {
        if (usInstanceID <= 0 || usInstanceID > GetMaxInstance())
        {
            CT_ERROR(("%d", usInstanceID));
            return RET_SYS_ERROR;
        }

        ucGrade = 0;

        int iIndex = (usInstanceID - 1) / GetGradCountPerData();

        if (iIndex >= _astGradeDatas.Size())
        {
            return 0;
        }

        unsigned char ucMask = 0;
        for (int i = 0; i < BITS_PER_GRAD; ++i)
        {
            ucMask |= (1 << i);
        }

        int iMoveCount = ((usInstanceID - 1) % GetGradCountPerData() * BITS_PER_GRAD);
        ucGrade = ((_astGradeDatas[iIndex] >> iMoveCount ) & (T_INS_GRAD_DATA)ucMask);
        return 0;
    }

public:
    CTArray<T_INS_GRAD_DATA, COUNT> _astGradeDatas;
};

typedef CInstanceGrade<50> CLargeInstanceGrade; //可以存50 * 21个副本
typedef CInstanceGrade<12> CSmallInstanceGrade; //可以存12 * 21个副本
typedef CInstanceGrade<2> CSecretInstanceGrade; //秘境评分

BEGIN_CODE_CONVERT(CLargeInstanceGrade)
CODE_CONVERT(_astGradeDatas)
END_CODE_CONVERT(CLargeInstanceGrade)

BEGIN_CODE_CONVERT(CSmallInstanceGrade)
CODE_CONVERT(_astGradeDatas)
END_CODE_CONVERT(CSmallInstanceGrade)

BEGIN_CODE_CONVERT(CSecretInstanceGrade)
CODE_CONVERT(_astGradeDatas)
END_CODE_CONVERT(CSecretInstanceGrade)

//副本攻打状态信息
template<int COUNT>
class CInstanceAtkStat : public CTCodeObject
{
public:
    typedef uint64 T_INS_ATK_STAT_DATA;

    CInstanceAtkStat()
    {
        Clear();
    }

    void ClearStat()
    {
        _iLastAtkTime = 0;
        _usMaxAtkInstanceID = 0;
        for (int i = 0; i < _astAtkStatDatas.Size(); ++i)
        {
            _astAtkStatDatas[i] = 0;
        }
    }

    void Clear()
    {
        _astAtkStatDatas.m_iUsedCount = _astAtkStatDatas.GetCount();
        ClearStat();
    }

    int BitCountPerData()
    {
        return sizeof(T_INS_ATK_STAT_DATA) * 8;
    }

    bool HasAtked(int iNowTime)
    {
        if (!CTTimeUtils::IsSameDay(iNowTime, _iLastAtkTime, DATA_RESET_SEC_OF_DAY))
        {
            ClearStat();
            return false;
        }

        for (int i = 0; i < _astAtkStatDatas.Size(); ++i)
        {
            if (_astAtkStatDatas[i] != 0)
            {
                return true;
            }
        }

        return false;
    }

    int GetHasAtkedCount(int iNowTime)
    {
        if (!CTTimeUtils::IsSameDay(iNowTime, _iLastAtkTime, DATA_RESET_SEC_OF_DAY))
        {
            return 0;
        }

        int iCount = 0;
        for (int i = 0; i < _astAtkStatDatas.Size(); ++i)
        {
            if (_astAtkStatDatas[i] != 0)
            {
                T_INS_ATK_STAT_DATA stData = _astAtkStatDatas[i];
                while (stData)
                {
                    stData &= (stData - 1);
                    iCount++;
                }
            }
        }

        return iCount;
    }

    //攻打胜利
    int AtkWin(unsigned short usInstanceID, int iNowTime)
    {
        if (!CTTimeUtils::IsSameDay(iNowTime, _iLastAtkTime, DATA_RESET_SEC_OF_DAY))
        {
            ClearStat();
        }

        if (usInstanceID <= 0 || usInstanceID > _astAtkStatDatas.Size() * BitCountPerData())
        {
            CT_ERROR(("%d", usInstanceID));
            return ERROR_INSTANCE_ID;
        }

        for (int i = 0; i < _astAtkStatDatas.Size(); ++i)
        {
            if (usInstanceID < BitCountPerData())
            {
                _astAtkStatDatas[i] |= ((T_INS_ATK_STAT_DATA)1 << (usInstanceID - 1));
                _iLastAtkTime = iNowTime;
                _usMaxAtkInstanceID = CT_MAX(usInstanceID, _usMaxAtkInstanceID);
                return 0;
            }

            usInstanceID -= BitCountPerData();
        }

        return 0;
    }

    //检查是否已经攻打胜利过
    bool IsAtkWin(unsigned short usInstanceID, int iNowTime)
    {
        if (!CTTimeUtils::IsSameDay(iNowTime, _iLastAtkTime, DATA_RESET_SEC_OF_DAY))
        {
            return false;
        }

        if (usInstanceID <= 0 || usInstanceID > _astAtkStatDatas.Size() * BitCountPerData())
        {
            CT_ERROR(("%d", usInstanceID));
            return false;
        }

        for (int i = 0; i < _astAtkStatDatas.Size(); ++i)
        {
            if (usInstanceID < BitCountPerData())
            {
                return (_astAtkStatDatas[i] & ((T_INS_ATK_STAT_DATA)1 << (usInstanceID - 1)));
            }

            usInstanceID -= BitCountPerData();
        }

        return false;
    }

    unsigned short GetMaxAtkInstanceID(int iNowTime)
    {
        if (!CTTimeUtils::IsSameDay(iNowTime, _iLastAtkTime, DATA_RESET_SEC_OF_DAY))
        {
            return 0;
        }

        return _usMaxAtkInstanceID;
    }

public:
    int _iLastAtkTime; //最后一次攻击时间
    unsigned short _usMaxAtkInstanceID;     //最大攻击到的副本ID
    CTArray<T_INS_ATK_STAT_DATA, COUNT> _astAtkStatDatas;
};

typedef CInstanceAtkStat<4> CSmallInstanceAtkStat; //可以存250个副本左右
BEGIN_CODE_CONVERT(CSmallInstanceAtkStat)
CODE_CONVERT(_iLastAtkTime)
CODE_CONVERT(_usMaxAtkInstanceID)
CODE_CONVERT(_astAtkStatDatas)
END_CODE_CONVERT(CSmallInstanceAtkStat)

typedef CInstanceAtkStat<1> CTinyInstanceAtkStat; //可以存64个副本攻击状态
BEGIN_CODE_CONVERT(CTinyInstanceAtkStat)
CODE_CONVERT(_iLastAtkTime)
CODE_CONVERT(_usMaxAtkInstanceID)
CODE_CONVERT(_astAtkStatDatas)
END_CODE_CONVERT(CTinyInstanceAtkStat)

//精英副本攻打状态
class CEliteInstanceAtkStat : public CTCodeObject
{
public:
    typedef int64 T_ELITE_STAT_DATA;

    CEliteInstanceAtkStat()
    {
        Clear();
    }

    void ClearStat()
    {
        for (int i = 0; i < _astAtkStat.Size(); ++i)
        {
            _astAtkStat[i].ClearStat();
        }
    }

    void ClearResetCount()
    {
        _astHasResetCount.Clear();
    }

    void Clear()
    {
        ClearStat();
        ClearResetCount();
    }

    static int GetMaxResetCount(unsigned char ucVipLevel)
    {
        if (ucVipLevel == 0)
        {
            return 0;
        }
        else if (ucVipLevel <= 3)
        {
            return 1;
        }
        else if (ucVipLevel <= 6)
        {
            return 2;
        }
        else if (ucVipLevel <= 10)
        {
            return 3;
        }
        else
        {
            return 4;
        }
    }

    //攻打胜利
    int AtkWin(int iIndex, unsigned short usInstanceID, int iNowTime)
    {
        if (iIndex < 0 || iIndex > MAX_INSTANCE_ELITE_CONFIG_COUNT)
        {
            CT_ERROR((""));
            return RET_SYS_ERROR;
        }

        while (iIndex >= _astAtkStat.Size())
        {
            _astAtkStat.AddOneItem(CSmallInstanceAtkStat());
        }

        return _astAtkStat[iIndex].AtkWin(usInstanceID, iNowTime);
    }

    //检查是否已经攻打胜利过
    bool IsAtkWin(int iIndex, unsigned short usInstanceID, int iNowTime)
    {
        if (iIndex < 0 || iIndex > MAX_INSTANCE_ELITE_CONFIG_COUNT)
        {
            CT_ERROR((""));
            return false;
        }

        if (iIndex >= _astAtkStat.Size())
        {
            return false;
        }

        return _astAtkStat[iIndex].IsAtkWin(usInstanceID, iNowTime);
    }

    int GetHasBuyResetCount(int iIndex, int iNowTime)
    {
        if (iIndex < 0 || iIndex > MAX_INSTANCE_ELITE_CONFIG_COUNT)
        {
            CT_WARNING((""));
            return 999;
        }

        if (iIndex >= _astHasResetCount.Size())
        {
            return 0;
        }

        return _astHasResetCount[iIndex].Get(iNowTime);
    }

    void AddHasBuyResetCount(int iIndex, int iNowTime)
    {
        if (iIndex < 0 || iIndex > MAX_INSTANCE_ELITE_CONFIG_COUNT)
        {
            CT_ERROR((""));
            return;
        }

        while(iIndex >= _astHasResetCount.Size())
        {
            CDailyReflushChar stTmp;
            stTmp.SetDefault(0);
            _astHasResetCount.AddOneItem(stTmp);
        }

        _astHasResetCount[iIndex].Add(1, iNowTime);
    }

    void ClearAtkStat(int iIndex)
    {
        if (iIndex < 0 || iIndex > MAX_INSTANCE_ELITE_CONFIG_COUNT)
        {
            CT_ERROR(("%d", iIndex));
            return;
        }

        if (iIndex >= _astAtkStat.Size())
        {
            return;
        }

        _astAtkStat[iIndex].ClearStat();
    }

    bool HasAtked(int iIndex, int iNowTime)
    {
        if (iIndex < 0 || iIndex > MAX_INSTANCE_ELITE_CONFIG_COUNT)
        {
            CT_ERROR((""));
            return false;
        }

        if (iIndex >= _astAtkStat.Size())
        {
            return false;
        }

        return _astAtkStat[iIndex].HasAtked(iNowTime);
    }

    int GetHasAtkedCount(int iIndex, int iNowTime)
    {
        if (iIndex < 0 || iIndex > MAX_INSTANCE_ELITE_CONFIG_COUNT)
        {
            CT_ERROR((""));
            return 0;
        }

        if (iIndex >= _astAtkStat.Size())
        {
            return 0;
        }

        return _astAtkStat[iIndex].GetHasAtkedCount(iNowTime);
    }

    CTLib::CTArray<CSmallInstanceAtkStat, MAX_INSTANCE_ELITE_CONFIG_COUNT + 1> _astAtkStat;       //攻击次数计数器
    CTLib::CTArray<CDailyReflushChar, MAX_INSTANCE_ELITE_CONFIG_COUNT + 1> _astHasResetCount;        //重置计数器
};

BEGIN_CODE_CONVERT(CEliteInstanceAtkStat)
CODE_CONVERT(_astAtkStat)
CODE_CONVERT(_astHasResetCount)
END_CODE_CONVERT(CEliteInstanceAtkStat)

//秘境数据
class CSecretInstanceData : public CTCodeObject
{
public:
    CSecretInstanceData()
    {
        Clear();
    }

    void Clear()
    {
        _stGrade.Clear();
        _astAtkStats.Clear();

        _iLastResetTime = 0;
        _acResetCount.Clear();
    }

    //检查是否可以重置
    bool IsCanReset(unsigned char ucSecretID, int iCanResetCount, int iNowTime)
    {
        if (ucSecretID <= 0 || ucSecretID > MAX_INSTANCE_SECRET_CONFIG_COUNT)
        {
            return false;
        }

        if (_astAtkStats.Size() <= ucSecretID
            || !_astAtkStats[ucSecretID].IsAtkWin(1, iNowTime)) //没打过不能RESET
        {
            return false;
        }

        return iCanResetCount > GetResetCount(ucSecretID, iNowTime);
    }

    //重置
    void Reset(unsigned char ucSecretID, int iNowTime)
    {
        if (ucSecretID <= 0 || ucSecretID > MAX_INSTANCE_SECRET_CONFIG_COUNT)
        {
            CT_ERROR(("%d", ucSecretID));
            return;
        }

        //增加次数
        AddResetCount(ucSecretID, iNowTime);

        //重置副本
        _astAtkStats[ucSecretID].ClearStat();
    }

    //获取当前已重置次数
    int GetResetCount(unsigned char ucSecretID, int iNowTime)
    {
        if (ucSecretID <= 0 || ucSecretID > MAX_INSTANCE_SECRET_CONFIG_COUNT)
        {
            CT_ERROR(("%d", ucSecretID));
            return 9999;
        }

        if (CTTimeUtils::IsSameDay(iNowTime, _iLastResetTime, DATA_RESET_SEC_OF_DAY))
        {
            return _acResetCount[ucSecretID];
        }

        return 0;
    }

    //增加重置次数
    int AddResetCount(unsigned char ucSecretID, int iNowTime)
    {
        if (ucSecretID <= 0 || ucSecretID > MAX_INSTANCE_SECRET_CONFIG_COUNT)
        {
            CT_ERROR(("%d", ucSecretID));
            return RET_SYS_ERROR;
        }

        if (!CTTimeUtils::IsSameDay(iNowTime, _iLastResetTime, DATA_RESET_SEC_OF_DAY))
        {
            _acResetCount.Clear();
        }

        while (ucSecretID >= _acResetCount.Size())
        {
            _acResetCount.AddOneItem(0);
        }

        _acResetCount[ucSecretID] += 1;
        _iLastResetTime = iNowTime;

        return 0;
    }

    int AtkWin(unsigned char ucSecID, unsigned short usInstanceID, int iNowTime)
    {
        if (ucSecID <= 0 || ucSecID > MAX_INSTANCE_SECRET_CONFIG_COUNT)
        {
            return RET_SYS_ERROR;
        }

        while (ucSecID >= _astAtkStats.Size())
        {
            _astAtkStats.AddOneItem(CTinyInstanceAtkStat());
        }

        return _astAtkStats[ucSecID].AtkWin(usInstanceID, iNowTime);
    }

    bool IsAtkWin(unsigned char ucSecID, unsigned short usInstanceID, int iNowTime)
    {
        if (ucSecID <= 0 || ucSecID > MAX_INSTANCE_SECRET_CONFIG_COUNT)
        {
            return false;
        }

        if (ucSecID >= _astAtkStats.Size())
        {
            return false;
        }

        return _astAtkStats[ucSecID].IsAtkWin(usInstanceID, iNowTime);
    }

    unsigned short GetMaxAtkInstanceID(unsigned char ucSecID, int iNowTime)
    {
        if (ucSecID <= 0 || ucSecID > MAX_INSTANCE_SECRET_CONFIG_COUNT)
        {
            return 0;
        }

        if (ucSecID >= _astAtkStats.Size())
        {
            return 0;
        }

        return _astAtkStats[ucSecID].GetMaxAtkInstanceID(iNowTime);
    }

public:
    CSecretInstanceGrade _stGrade;                                                       //各秘境评分(各接口参数用秘境ID而不是副本ID)
    CTLib::CTArray<CTinyInstanceAtkStat, MAX_INSTANCE_SECRET_CONFIG_COUNT + 1> _astAtkStats; //各秘境攻打状态

    int _iLastResetTime;            //最后一次重置时间
    CTLib::CTArray<char, MAX_INSTANCE_SECRET_CONFIG_COUNT + 1> _acResetCount;           //重置次数
};
BEGIN_CODE_CONVERT(CSecretInstanceData)
CODE_CONVERT(_stGrade)
CODE_CONVERT(_astAtkStats)

CODE_CONVERT(_iLastResetTime)
CODE_CONVERT(_acResetCount)
END_CODE_CONVERT(CSecretInstanceData)

//博物馆用户数据
class CMuseumInstanceData : public CTCodeObject
{
public:
    CMuseumInstanceData()
    {
        _iTotalAtkCount = 0;

        _iLastSweepTime = 0;
        _iBuySweepCount = 0;

        _usNowSweepInstanceID = 0;
        _usMaxSweepInstanceID = 0;

        _iHasBuySweepCount = 0;
        _iLastBuySweepTime = 0;
        _iFreeSweepCount = 0;
    }

    int GetBuySweepCountPrice(int iNowTime, int& iNeedGold, int iMaxCanBuySweepCount)
    {
        int iHasBuySweepCount = GetHasBuySweepCount(iNowTime);

        iNeedGold = 0;

        if (iHasBuySweepCount >= iMaxCanBuySweepCount)
        {
            return ERROR_INSTANCE_MUSEUM_SWEEP_BUY_MAX;
        }

        switch (iHasBuySweepCount)
        {
        case 0:
            iNeedGold = 50;
            break;
        case 1:
            iNeedGold = 200;
            break;
        case 2:
            iNeedGold = 400;
            break;
        default:
            return ERROR_INSTANCE_MUSEUM_SWEEP_BUY_MAX;
        }

        if (iNeedGold < 0)
        {
            return ERROR_GOLD_VALID;
        }

        return 0;
    }

    int AddBuySweepCount(int iNowTime)
    {
        int iHasBuySweepCount = GetHasBuySweepCount(iNowTime);

        //增加次数
        _iBuySweepCount++;
        _iHasBuySweepCount = iHasBuySweepCount + 1;
        _iLastBuySweepTime = iNowTime;

        return 0;
    }

    int GetSweepCount(int iNowTime)
    {
        return GetFreeSweepCount(iNowTime) + _iBuySweepCount;
    }

    int GetFreeSweepCount(int iNowTime)
    {
        if (!CTTimeUtils::IsSameDay(iNowTime, _iLastSweepTime, DATA_RESET_SEC_OF_DAY))
        {
            return INSTANCE_MUSEUM_FREE_RESET_COUNT;
        }

        return _iFreeSweepCount;
    }

    int GetHasBuySweepCount(int iNowTime)
    {
        if (!CTTimeUtils::IsSameDay(iNowTime, _iLastBuySweepTime, DATA_RESET_SEC_OF_DAY))
        {
            return 0;
        }

        return _iHasBuySweepCount;
    }

    int UseSweepCount(int iNowTime)
    {
        _iFreeSweepCount = GetFreeSweepCount(iNowTime);

        if (_iFreeSweepCount <= 0)
        {
            if (_iBuySweepCount <= 0)
            {
                return ERROR_INSTANCE_MUSEUM_SWEEP_MAX;
            }
            else
            {
                _iBuySweepCount--;
            }
        }
        else
        {
            _iFreeSweepCount--;
        }

        _iLastSweepTime = iNowTime;

        return 0;
    }

    //是否在扫荡过程中
    bool IsInSweep() const
    {
        return (_usNowSweepInstanceID < _usMaxSweepInstanceID);
    }

public:
    int _iTotalAtkCount;  //累计攻打雕像数量

    int _iLastSweepTime;        //最后一次扫荡时间
    int _iBuySweepCount;        //购买的扫荡次数

    unsigned short _usNowSweepInstanceID; //当前扫荡到哪个副本
    unsigned short _usMaxSweepInstanceID; //最大可扫荡到哪个副本

    int _iHasBuySweepCount;     //当前购买的扫荡次数
    int _iLastBuySweepTime;     //上次购买扫荡次数的时间
    int _iFreeSweepCount;       //当天免费扫荡次数
};
BEGIN_CODE_CONVERT(CMuseumInstanceData)
CODE_CONVERT(_iTotalAtkCount)
CODE_CONVERT(_iLastSweepTime)
CODE_CONVERT(_iBuySweepCount)
CODE_CONVERT(_usNowSweepInstanceID)
CODE_CONVERT(_usMaxSweepInstanceID)

CODE_CONVERT(_iHasBuySweepCount)
CODE_CONVERT(_iLastBuySweepTime)
CODE_CONVERT(_iFreeSweepCount)
END_CODE_CONVERT(CMuseumInstanceData)

class CInstanceGradeBonusData : public CTCodeObject
{
public:
    CInstanceGradeBonusData()
    {
        _aucGradeBonusStates.Clear();
    }

    //ucPos表示第几个礼包，从0开始，最多只有3个礼包
    int Set(int iBonusID, unsigned char ucPos)
    {
        if (iBonusID <= 0 || iBonusID >= _aucGradeBonusStates.GetCount()
            || ucPos >= MAX_GRADE_BONUS_COUNT_PER_MAP)
        {
            CT_ERROR((""));
            return RET_SYS_ERROR;
        }

        while (iBonusID >= _aucGradeBonusStates.Size())
        {
            _aucGradeBonusStates.AddOneItem(0);
        }

        _aucGradeBonusStates[iBonusID] |= (1 << ucPos);
        return 0;
    }

    bool IsSet(int iBonusID, unsigned char ucPos)
    {
        if (iBonusID <= 0 || iBonusID >= _aucGradeBonusStates.GetCount()
            || ucPos >= MAX_GRADE_BONUS_COUNT_PER_MAP)
        {
            CT_ERROR((""));
            return false;
        }

        if (iBonusID >= _aucGradeBonusStates.Size())
        {
            return false;
        }

        return _aucGradeBonusStates[iBonusID] & (1 << ucPos);
    }

public:
    CTLib::CTArray<unsigned char, MAX_GRADE_BONUS_COUNT + 1> _aucGradeBonusStates; //奖励状态信息，是否已经领过
};

BEGIN_CODE_CONVERT(CInstanceGradeBonusData)
CODE_CONVERT(_aucGradeBonusStates)
END_CODE_CONVERT(CInstanceGradeBonusData)

class CInstanceData : public CTCodeObject
{
public:
    CInstanceData()
    {
        Clear();
    }

    void Clear()
    {
        _stHasOpenedInstanceData.Clear();
        _stHasFinishedInstanceData.Clear();
    }

    void SetEliteGrade(int iIndex, unsigned short usInstanceID, unsigned char ucGrade)
    {
        if (iIndex < 0 || iIndex >= _astEliteInstanceGrad.GetCount())
        {
            CT_WARNING((""));
            return;
        }

        while (iIndex >= _astEliteInstanceGrad.Size())
        {
            _astEliteInstanceGrad.AddOneItem(CSmallInstanceGrade());
        }

        _astEliteInstanceGrad[iIndex].SetGrad(usInstanceID, ucGrade);
    }

    CInstanceDetailStatData _stMainDetailStat;                                          //主线副本详细状态(只指向最后那个副本)
    CInstanceDetailStatData _stChallengeDetailStat;                                     //挑战副本详细状态(只指向最后那个副本)
    CTArray<CInstanceDetailStatData, MAX_INSTANCE_BRANCH_COUNT> _astBranchDetailStat;   //其他副本详细状态

    CInstanceStatData                  _stHasOpenedInstanceData;      //可进入的副本
    CInstanceStatData                  _stHasFinishedInstanceData;    //可扫荡的副本
    CEliteInstanceAtkStat              _stEliteAtkStat;               //精英副本攻打状态

    CLargeInstanceGrade                _stMainInstanceGrad;            //主线副本评分
    CTLib::CTArray<CSmallInstanceGrade, MAX_INSTANCE_SECRET_CONFIG_COUNT>                _astEliteInstanceGrad;        //精英副本评分

    CSecretInstanceData                _stSecretInstanceData;           //秘境数据
    CMuseumInstanceData                _stMuseumInstanceData;           //博物馆数据

    CInstanceGradeBonusData            _stGradeBonusStat;               //星级奖励礼包领取状态
};

BEGIN_CODE_CONVERT(CInstanceData)
CODE_CONVERT(_stMainDetailStat)
CODE_CONVERT(_stChallengeDetailStat)
CODE_CONVERT(_astBranchDetailStat)

CODE_CONVERT(_stHasOpenedInstanceData)
CODE_CONVERT(_stHasFinishedInstanceData)

CODE_CONVERT(_stEliteAtkStat)

CODE_CONVERT(_stMainInstanceGrad)
CODE_CONVERT(_astEliteInstanceGrad)

CODE_CONVERT(_stSecretInstanceData)
CODE_CONVERT(_stMuseumInstanceData)

CODE_CONVERT(_stGradeBonusStat)
END_CODE_CONVERT(CInstanceData)

//副本全局数据
class CInstanceZoneData : public CTCodeObject
{
public:
    CInstanceZoneData()
    {

    }

public:
    CTLib::CTArray<CInstanceMuseumRankData, MAX_INSTANCE_MUSEUM_RANK_LEN> _astMuseumRank; //博物馆排名
};

BEGIN_CODE_CONVERT(CInstanceZoneData)
CODE_CONVERT(_astMuseumRank)
END_CODE_CONVERT(CInstanceZoneData)

//////////////////////////////////////////////////////////////////////////

//魂器数据
class CPlayerSoulData : public CTCodeObject
{
public:
    CPlayerSoulData()
    {
        Clear();
    }

    void Clear()
    {
        _ucNowStat = 1;

        _astNowBallLevel.m_iUsedCount = _astNowBallLevel.GetCount();
        for (int i = 0; i < _astNowBallLevel.Size(); ++i)
        {
            _astNowBallLevel[i] = 0;
        }
    }

    int StatUp()
    {
        if (_ucNowStat >= MAX_SOUL_STAT_LEVEL)
        {
            return ERROR_SOUL_STAT_MAX_LEVEL;
        }

        _astNowBallLevel.m_iUsedCount = _astNowBallLevel.GetCount();
        for (int i = 0; i < _astNowBallLevel.Size(); ++i)
        {
            _astNowBallLevel[i] = 0;
        }

        _ucNowStat++;
        return 0;
    }

    bool IsMaxLevel(unsigned char ucBallID)
    {
        if (ucBallID <= 0 || ucBallID > MAX_SOUL_MAX_BALL_COUNT)
        {
            return false;
        }

        return _astNowBallLevel[ucBallID] >= MAX_SOUL_MAX_BALL_LEVEL;
    }

    int LevelUp(unsigned char ucBallID)
    {
        if (ucBallID <= 0 || ucBallID > MAX_SOUL_MAX_BALL_COUNT)
        {
            return ERROR_SOUL_BALL_ID;
        }

        if (_astNowBallLevel[ucBallID] >= MAX_SOUL_MAX_BALL_LEVEL)
        {
            return ERROR_SOUL_BALL_MAX_LEVEL;
        }

        _astNowBallLevel[ucBallID]++;
        return 0;
    }

    int GetBallLevel(unsigned char ucBallID, unsigned char& ucBallLevel)
    {
        if (ucBallID <= 0 || ucBallID > MAX_SOUL_MAX_BALL_COUNT)
        {
            return ERROR_SOUL_BALL_ID;
        }

        ucBallLevel = _astNowBallLevel[ucBallID];
        return 0;
    }

public:
    unsigned int _uiGID;    //不入库
    unsigned char _ucNowStat;   //当前在哪个阶段
    CTLib::CTArray<unsigned char, MAX_SOUL_MAX_BALL_COUNT + 1> _astNowBallLevel;
};

BEGIN_CODE_CONVERT(CPlayerSoulData)
CODE_CONVERT(_ucNowStat)
CODE_CONVERT(_astNowBallLevel)
END_CODE_CONVERT(CPlayerSoulData)

class CShopItemData : public CTCodeObject
{
public:
    CShopItemData()
    {
        Clear();
    }

    void Clear()
    {
        _ucItemType = 0;
        _usItemID  = 0;
        _usItemCnt = 0;
        _ucIsSaleOut = true;  // 是否卖光了
    }

public:
    unsigned char _ucItemType;
    unsigned char _ucIsSaleOut;
    unsigned short _usItemID;
    unsigned short _usItemCnt;
};
BEGIN_CODE_CONVERT(CShopItemData)
CODE_CONVERT(_ucItemType)
CODE_CONVERT(_ucIsSaleOut)
CODE_CONVERT(_usItemID)
CODE_CONVERT(_usItemCnt)
END_CODE_CONVERT(CShopItemData)

//商店: 当前只有神秘\家族商店数据需要入库
class CShopData : public CTCodeObject
{
public:
    CShopData()
    {
        Clear();
    }

    void Clear()
    {
        _ucCaneCnt = 0;
        _ucGoldRefreshCnt = 0;
        _iRenewCaneTime = 0;
        _iClearCntTime = 0;
        _astShopItem.Clear();
        _iLastBuyTime = 0;
        _astBuyItems.Clear();
        _iClearCrystalShopTime = 0;
        _astCrystalItems.Clear();
    }

public:
    unsigned char _ucCaneCnt;
    unsigned char _ucGoldRefreshCnt;
    int _iRenewCaneTime;  //下次计算更新魔杖数量的时间
    int _iClearCntTime;   //下次清空金币刷新次数的时间
    CTArray<CShopItemData, MAX_MYSTICAL_SHOP_GRID_NUM> _astShopItem;

    int _iLastBuyTime;  //最后一次购买家族商店物品时间
    CTArray<unsigned char, MAX_CLAN_SHOP_ITEM> _astBuyItems; //已在家族商店购买的物品下标

    int _iClearCrystalShopTime;  //最后一次购买宝石商店物品时间
    CTArray<unsigned char, MAX_CRYSTAL_SHOP_COUNT> _astCrystalItems; //已在宝石商店购买的物品下标
};
BEGIN_CODE_CONVERT(CShopData)
CODE_CONVERT(_ucCaneCnt)
CODE_CONVERT(_ucGoldRefreshCnt)
CODE_CONVERT(_iRenewCaneTime)
CODE_CONVERT(_iClearCntTime)
CODE_CONVERT(_astShopItem)
CODE_CONVERT(_iLastBuyTime)
CODE_CONVERT(_astBuyItems)
CODE_CONVERT(_iClearCrystalShopTime)
CODE_CONVERT(_astCrystalItems)
END_CODE_CONVERT(CShopData)

class CUserEnergy : public CTCodeObject
{
public:
    enum
    {
        MAX_MEAL_TYPE_PER_DAY = 10, //表示每天最多可以吃10顿
        ENERGY_MEAL_LUNCH = 1,      //午餐
        ENERGY_MEAL_DINNER = 2,     //晚餐
    };

    CUserEnergy()
    {
        Clear();
    }

    void Clear()
    {
        _shEnergy = 0;
        _iEnergyGrowTime = 0;

        _iLastMealSeq = 0;

        _iHasBuyEnergyTimes = 0;
        _iLastBuyEnergyTime = 0;

        CleanMeal();
    }

    //获取购买精力的价格
    static int GetEnergyPrice(int iHasBuyTimes)
    {
        if (iHasBuyTimes < 1)
        {
            return 20;
        }
        else if (iHasBuyTimes < 10)
        {
            return 40;
        }
        else if (iHasBuyTimes < 20)
        {
            return 100;
        }
        else if (iHasBuyTimes < 40)
        {
            return 200;
        }

        return 500;
    }

    //获取就餐序列ID，每餐饭的ID是唯一的
    int GetMealSeq(int iNowTime, int& iSeq)
    {
        iSeq = CTTimeUtils::GetDaysOfSec(iNowTime) * 10; //10表示每天最多可以吃10顿，预留位置

        int iSec = CTTimeUtils::GetSecOfDay(iNowTime);
        if (iSec < ENERGY_FIRST_MEAL_BEGIN_HOUR * 3600)
        {
            return ERROR_ENERGY_NOT_MEAL_TIME;
        }
        else if (iSec < ENERGY_SECOND_MEAL_BEGIN_HOUR * 3600)
        {
            iSeq += ENERGY_MEAL_LUNCH;      //当天第一顿饭
        }
        else if (iSec < 24 * 3600)
        {
            iSeq += ENERGY_MEAL_DINNER;      //当天第二顿饭
        }

        return 0;
    }

    //是否是午餐
    bool IsLunch(int iSeq)
    {
        return ((iSeq % 10) == ENERGY_MEAL_LUNCH);
    }

    //是否是晚餐
    bool IsDinner(int iSeq)
    {
        return ((iSeq % 10) == ENERGY_MEAL_DINNER);
    }

    //是否吃饭时间
    bool IsMealTime(int iNowTime)
    {
        return CTTimeUtils::GetSecOfDay(iNowTime) >= ENERGY_FIRST_MEAL_BEGIN_HOUR * 3600;
    }

    //提供的菜品选择数
    int GetMealCount(int iNowTime)
    {
        return MAX_ENERGY_NORMAL_NOW_CAN_EAT_COUNT;       //现在统一都是3个
    }

    //获取精力数量
    int GetEnergy(int iNowTime) const
    {
        if (_shEnergy >= MAX_ENERGY_GROW_COUNT)
        {
            return _shEnergy;
        }

        return CT_MIN(MAX_ENERGY_GROW_COUNT,
                        ((iNowTime - _iEnergyGrowTime) / MAX_ENERGY_GROW_INTERVAL * MAX_ENERGY_GROW_COUNT_PER_INTERVAL + _shEnergy));
    }

    //
    int GetRealEnergy(int iNowTime)
    {
        if (_shEnergy >= MAX_ENERGY_GROW_COUNT)
        {
            return _shEnergy;
        }

        while (_shEnergy < MAX_ENERGY_GROW_COUNT && (_iEnergyGrowTime + MAX_ENERGY_GROW_INTERVAL) < iNowTime)
        {
            _shEnergy = CT_MIN(_shEnergy + MAX_ENERGY_GROW_COUNT_PER_INTERVAL, MAX_ENERGY_GROW_COUNT) ;
            _iEnergyGrowTime += MAX_ENERGY_GROW_INTERVAL;
        }

        return _shEnergy;
    }

    //判断精力是否已满
    bool IsFull(int iNowTime) const
    {
        return GetEnergy(iNowTime) >= MAX_ENERGY_GROW_COUNT;
    }

    //扣除精力
    int SubEnergy(short shCount, int iNowTime)
    {
        if (shCount <= 0)
        {
            CT_WARNING((""));
            return 0;
        }

        short shNowEnergy = GetRealEnergy(iNowTime);
        if (shCount > shNowEnergy)
        {
            return ERROR_ENERGY_LESS;
        }

        _shEnergy =  shNowEnergy - shCount;
        if (shNowEnergy >= MAX_ENERGY_GROW_COUNT
            && _shEnergy < MAX_ENERGY_GROW_COUNT)
        {
            _iEnergyGrowTime = iNowTime;
        }

        return 0;
    }

    //添加精力
    int AddEnergy(short shCount, int iNowTime)
    {
        if (shCount <= 0)
        {
            CT_WARNING((""));
            return 0;
        }

        short shNowEnergy = GetRealEnergy(iNowTime);

        _shEnergy = CT_MIN(MAX_ENERGY_COUNT, shNowEnergy + shCount);
        return 0;
    }

    //获取已经购买精力的次数
    int GetHasBuyEnergyCount(int iNowTime)
    {
        if (CTTimeUtils::IsSameDay(iNowTime, _iLastBuyEnergyTime, DATA_RESET_SEC_OF_DAY))
        {
            return _iHasBuyEnergyTimes;
        }

        return 0;
    }

    //增加购买次数
    void AddBuyEnergyCount(int iNowTime)
    {
        _iHasBuyEnergyTimes = GetHasBuyEnergyCount(iNowTime) + 1;
        _iLastBuyEnergyTime = iNowTime;
    }

    //清理菜品
    void CleanMeal()
    {
        _aucNormalMeal.m_iUsedCount = _aucNormalMeal.GetCount();
        _aucMagicMeal.m_iUsedCount = _aucMagicMeal.GetCount();

        for (int i = 0; i < _aucNormalMeal.Size(); ++i)
        {
            _aucNormalMeal[i] = 0;
        }

        for (int i = 0; i < _aucMagicMeal.Size(); ++i)
        {
            _aucMagicMeal[i] = 0;
        }
    }

public:
    unsigned int _uiGID; //不入库
    short _shEnergy;            //精力数量
    int _iEnergyGrowTime;       //精力恢复开始时间

    int _iLastMealSeq;          //最近一顿饭的序列号
    CTArray<unsigned char, MAX_ENERGY_NORMAL_MEAL_COUNT> _aucNormalMeal;        //普通的菜品
    CTArray<unsigned char, MAX_ENERGY_MAGIC_MEAL_COUNT> _aucMagicMeal;          //魔力锅中的菜品

    int _iHasBuyEnergyTimes;        //已经购买的精力数
    int _iLastBuyEnergyTime;        //上次购买精力的时间
};

BEGIN_CODE_CONVERT(CUserEnergy)
CODE_CONVERT(_shEnergy)
CODE_CONVERT(_iEnergyGrowTime)

CODE_CONVERT(_iLastMealSeq)
CODE_CONVERT(_aucNormalMeal)
CODE_CONVERT(_aucMagicMeal)

CODE_CONVERT(_iHasBuyEnergyTimes)
CODE_CONVERT(_iLastBuyEnergyTime)
END_CODE_CONVERT(CUserEnergy)

class CYellowGiftData : public CTCodeObject //黄钻礼包数据
{
public:
    CYellowGiftData()
    {
        Clear();
    }

    void Clear()
    {
        _stHasGetDayGift.SetDefault(0);
        _stHasGetYearDayGift.SetDefault(0);
        _ucHasGetNewbieGift = 0;
        _ucHasGetMount = 0;
    }

    bool HasGetLevelGift(short shLevel)
    {
        int iLevelIndex = shLevel / 10;

        if (iLevelIndex > MAX_YELLOW_LEVEL_GIFT_COUNT)
        {
            CT_WARNING((""));
            return true;
        }

        if (_aucHasGetLevelGift.Size() <= iLevelIndex - 1)
        {
            return false;
        }

        return _aucHasGetLevelGift[iLevelIndex - 1] != 0;
    }

    void SetGetLevelGift(short shLevel)
    {
        int iLevelIndex = shLevel / 10;

        if (iLevelIndex > MAX_YELLOW_LEVEL_GIFT_COUNT)
        {
            CT_WARNING((""));
            return;
        }

        while (_aucHasGetLevelGift.Size() <= iLevelIndex - 1)
        {
            _aucHasGetLevelGift.AddOneItem(0);
        }

        _aucHasGetLevelGift[iLevelIndex - 1] = 1;
    }

    CDailyReflushChar _stHasGetDayGift;   //是否已领取黄钻每日礼包
    CDailyReflushChar _stHasGetYearDayGift; //是否已领取年费黄钻每日礼包
    unsigned char _ucHasGetNewbieGift;      //是否已领取黄钻新手礼包
    CTLib::CTArray<unsigned char, MAX_YELLOW_LEVEL_GIFT_COUNT> _aucHasGetLevelGift; //是否已领取黄钻等级礼包, 从0开始
    unsigned char _ucHasGetMount;

};
BEGIN_CODE_CONVERT(CYellowGiftData)
CODE_CONVERT(_stHasGetDayGift)
CODE_CONVERT(_stHasGetYearDayGift)
CODE_CONVERT(_ucHasGetNewbieGift)
CODE_CONVERT(_aucHasGetLevelGift)
CODE_CONVERT(_ucHasGetMount)
END_CODE_CONVERT(CYellowGiftData)

class CBlueGiftData : public CTCodeObject //蓝钻礼包数据
{
public:
    CBlueGiftData()
    {
        Clear();
    }

    void Clear()
    {
        _stHasGetDayGift.SetDefault(0);
        _stHasGetYearDayGift.SetDefault(0);
        _ucHasGetNewbieGift = 0;
        _ucHasGetMount = 0;
    }

    bool HasGetLevelGift(short shLevel)
    {
        int iLevelIndex = shLevel / 10;

        if (iLevelIndex > MAX_YELLOW_LEVEL_GIFT_COUNT)
        {
            CT_WARNING((""));
            return true;
        }

        if (_aucHasGetLevelGift.Size() <= iLevelIndex - 1)
        {
            return false;
        }

        return _aucHasGetLevelGift[iLevelIndex - 1] != 0;
    }

    void SetGetLevelGift(short shLevel)
    {
        int iLevelIndex = shLevel / 10;

        if (iLevelIndex > MAX_YELLOW_LEVEL_GIFT_COUNT)
        {
            CT_WARNING((""));
            return;
        }

        while (_aucHasGetLevelGift.Size() <= iLevelIndex - 1)
        {
            _aucHasGetLevelGift.AddOneItem(0);
        }

        _aucHasGetLevelGift[iLevelIndex - 1] = 1;
    }

    CDailyReflushChar _stHasGetDayGift;   //是否已领取蓝钻每日礼包
    CDailyReflushChar _stHasGetYearDayGift; //是否已领取年费蓝钻每日礼包
    CDailyReflushChar _stHasGetSuperDayGift; //是否已领取豪华蓝钻每日礼包
    unsigned char _ucHasGetNewbieGift;      //是否已领取蓝钻新手礼包
    CTLib::CTArray<unsigned char, MAX_BLUE_LEVEL_GIFT_COUNT> _aucHasGetLevelGift; //是否已领取蓝钻等级礼包, 从0开始
    CDailyReflushChar _stHasGet3366DayGift; //是否已经领取3366每日礼包
    unsigned char _ucHasGetMount;
};
BEGIN_CODE_CONVERT(CBlueGiftData)
CODE_CONVERT(_stHasGetDayGift)
CODE_CONVERT(_stHasGetYearDayGift)
CODE_CONVERT(_stHasGetSuperDayGift)
CODE_CONVERT(_ucHasGetNewbieGift)
CODE_CONVERT(_aucHasGetLevelGift)
CODE_CONVERT(_stHasGet3366DayGift)
CODE_CONVERT(_ucHasGetMount)
END_CODE_CONVERT(CBlueGiftData)

//玩家冻结数据
class CFreezeData : public CTCodeObject
{
public:
    CFreezeData()
    {
        Clear();
    }

    void Clear()
    {
        _iLoginLimit = 0;
        _iSpeakLimit = 0;
        _iGoldLimit = 0;
        _iSilverLimit = 0;
        _iBagLimit = 0;
        _iStorgeLimit = 0;
    }

public:
    int     _iLoginLimit;
    int     _iSpeakLimit;
    int     _iGoldLimit;
    int     _iSilverLimit;
    int     _iBagLimit;
    int     _iStorgeLimit;
};
BEGIN_CODE_CONVERT(CFreezeData)
CODE_CONVERT(_iLoginLimit)
CODE_CONVERT(_iSpeakLimit)
CODE_CONVERT(_iGoldLimit)
CODE_CONVERT(_iSilverLimit)
CODE_CONVERT(_iBagLimit)
CODE_CONVERT(_iStorgeLimit)
END_CODE_CONVERT(CFreezeData)

/////////////////////////////////////////////////////////////////////////
class CPlayerBaseInfo : public CTCodeObject
{
public:
    CPlayerBaseInfo()
    {
        _uiGID = 0;
        _sUserToken.Set("");
        _sRoleName.Set("");
        _ucIsMale = 0;
        _ucCareer = 0;
        _ucAcademy = 0;
        _ucIsInited = 0;

        _iTotalOnlineTime = 0;
        _iDefTotalOnlineTime = 0;
        _iDefendValidInfo = 2;
        _iOnlineTimeSinceReg = 0;

        _uiMapID = 0;
        _usXPos = 0;
        _usYPos = 0;

        _shLevel = 0;
        _i64NowExp = 0;
        _shActiveValue = 0;
        _iLevelUpTime = 0;

        _uiExerciseValue = 0;
        _aucPassiveSkillLevel.Clear();
        _aucTrainingCampRound.Clear();

        _chVipLevel = 0;
        _iGold = 0;
        _i64Silver = 0;
        _iRomany = 0;
        _iFateForce = 0;
        _iHunli = 0;

        _ucGloryLevel = 0;
        _usGloryLevelUpExp = 0;
        _shNowGloryExp = 0;
        _auiGloryStats.Clear();

        _usArenaRank = 0;
        _shWinningStreak = 0;

        _stUserTaskData.Clear();

        _stUserDailyTaskData.Clear();

        _stUserPetData.Clear();

        _stVipData.Clear();

        _stUserAuctionData.Clear();

        _stInstanceData.Clear();
        _stUserEnergy.Clear();
        _stYellowGiftData.Clear();
        _stFreezeData.Clear();

        _ucCrystalPotenLevel = 0;
        _iCrystalPotenExp = 0;
        _uiActStatus = 0;
    }

    //增加命运之力
    static int AddFateForce(int& iNowFateForce, int iToAddCount)
    {
        if (iToAddCount < 0)
        {
            return ERROR_FATE_FORCE_VALID;
        }

        //判断是否会溢出
        if ((iNowFateForce + iNowFateForce) & 0x80000000)
        {
            return ERROR_FATE_FORCE_OVER;
        }

        iNowFateForce += iToAddCount;
        return 0;
    }

    //扣除命运之力
    static int SubFateForce(int& iNowFateForce, int iToSubCount)
    {
        if (iToSubCount < 0)
        {
            return ERROR_FATE_FORCE_VALID;
        }

        //判断是否会溢出
        if (iNowFateForce < iToSubCount)
        {
            return ERROR_FATE_FORCE_LESS;
        }

        iNowFateForce -= iToSubCount;
        return 0;
    }

    //加金币
    static int AddGold(int & iNowGold, int iToAddGold)
    {
        if (iToAddGold < 0)
        {
            return ERROR_GOLD_VALID;
        }

        //判断是否会溢出
        if ((iNowGold + iToAddGold) & 0x80000000)
        {
            return ERROR_GOLD_OVER;
        }

        iNowGold += iToAddGold;
        return 0;
    }

    //扣金币
    static int SubGold(int & iNowGold, int iToSubGold)
    {
        if (iToSubGold < 0)
        {
            return ERROR_GOLD_VALID;
        }

        //判断是否会溢出
        if (iNowGold < iToSubGold)
        {
            return ERROR_GOLD_LESS;
        }

        iNowGold -= iToSubGold;
        return 0;
    }

    //加银币
    static int AddSilver(int64 & i64NowSilver, int iToAddSilver)
    {
        if (iToAddSilver < 0)
        {
            return ERROR_SILVER_VALID;
        }

        //判断是否会溢出
        if ((i64NowSilver + iToAddSilver) & 0x8000000000000000)
        {
            return ERROR_SILVER_OVER;
        }

        i64NowSilver += iToAddSilver;
        return 0;
    }

    //扣银币
    static int SubSilver(int64 & i64NowSilver, int iSubSilver)
    {
        if (iSubSilver < 0)
        {
            return ERROR_SILVER_VALID;
        }

        //判断是否会溢出
        if (i64NowSilver < iSubSilver)
        {
            return ERROR_SILVER_LESS;
        }

        i64NowSilver -= iSubSilver;
        return 0;
    }

    //检查int属性值
    static int CheckIntValue(int& iBaseInt, int iChkInt)
    {
        if (iBaseInt < 0)
        {
            return ERROR_BASE_INT_VALID;
        }

        //iChkInt 正数表示加上 负数表示减去
        if (0 == iChkInt)
        {
            return 0;
        }
        else if (iChkInt > 0)
        {
            if ((iBaseInt + iChkInt) & 0x80000000)
            {
                return ERROR_BASE_INT_OVER;
            }
        }
        else if (iChkInt < 0)
        {
            if (iBaseInt + iChkInt < 0)
            {
                return ERROR_BASE_INT_LESS;
            }
        }

        return 0;
    }

    //修改int属性值
    static int ChangeIntValue(int& iBaseInt, int iChgInt)
    {
        int iRet = CheckIntValue(iBaseInt, iChgInt);
        CT_RETURN(iRet);

        iBaseInt += iChgInt;
        return 0;
    }

    //检查int64属性值
    static int CheckInt64Value(int64& i64BaseInt64, int64 i64ChkInt64)
    {
        if (i64BaseInt64 < 0)
        {
            return ERROR_BASE_LL_INT_VALID;
        }

        //i64ChkInt64 正数表示加上 负数表示减去
        if (0 == i64ChkInt64)
        {
            return 0;
        }
        else if (i64ChkInt64 > 0)
        {
            if ((i64BaseInt64 + i64ChkInt64) & 0x8000000000000000)
            {
                return ERROR_BASE_LL_INT_OVER;
            }
        }
        else if (i64ChkInt64 < 0)
        {
            if (i64BaseInt64 + i64ChkInt64 < 0)
            {
                return ERROR_BASE_LL_INT_LESS;
            }
        }

        return 0;
    }

    //修改int64属性值
    static int ChangeInt64Value(int64& i64BaseInt64, int64 i64ChgInt64)
    {
        int iRet = CheckInt64Value(i64BaseInt64, i64ChgInt64);
        CT_RETURN(iRet);

        i64BaseInt64 += i64ChgInt64;
        return 0;
    }

    static void TraceSize()
    {
        CT_TRACE(("CPlayerBaseInfo: %d", sizeof(CPlayerBaseInfo)));
    }

    void SetActOpen (int iAct)
    {
        CT_BIT_SET(_uiActStatus, iAct);
    }

    void SetActClose (int iAct)
    {
        CT_BIT_CLR(_uiActStatus, iAct);
    }

public:
    //角色信息
    unsigned int                _uiGID;
    CTSizeString<USER_TOKEN_LEN> _sUserToken;

    unsigned char               _ucIsInited;

    CTSizeString<ROLENAME_LEN>  _sRoleName;
    unsigned char               _ucIsMale;
    unsigned char               _ucCareer;
    unsigned char               _ucAcademy;

    //在线信息
    int _iTotalOnlineTime;                 //每天总累计在线时间
    int _iDefTotalOnlineTime;              //累计在线时间，防沉迷用
    int _iDefendValidInfo;                 //用户身份验证状态，1：验证通过， 0：未验证通过, 2: 初始化，从未验证过
    int _iOnlineTimeSinceReg;                 //注册后的累计在线时间

    //地图信息
    unsigned int                _uiMapID;               //所在地图信息
    unsigned short              _usXPos;               //所在地图的X坐标
    unsigned short              _usYPos;               //所在地图的Y坐标

    //等级信息
    short                       _shLevel;
    short                       _shActiveValue;       //活跃度
    int64                       _i64NowExp;           //当前经验
    int                         _iLevelUpTime;       //升级时间

    //历练信息
    unsigned int                _uiExerciseValue;         //历练
    CTArray<unsigned char, PASSIVE_SKILL_LEVEL_COUNT>      _aucPassiveSkillLevel;    //被动技能等级
    CTArray<unsigned char, TRAINING_CAMP_ROUND_COUNT>      _aucTrainingCampRound;     //训练营期数

    //付费信息
    char                        _chVipLevel;
    int                         _iGold;                 //金币。为了避免溢出变成极大值，这里用int
    int64                       _i64Silver;             //银币
    int                         _iRomany;               //吉普赛硬币
    int                         _iFateForce;            //命运之力
    int                         _iHunli;                //魂力

    //成就信息
    unsigned char               _ucGloryLevel;          //成就等级
    unsigned short              _usGloryLevelUpExp;     //成就升级所需分数
    short                       _shNowGloryExp;         //当前成就分数
    CTArray<unsigned int, GLORY_USE_INT_COUNT>          _auiGloryStats;  //成就达成记录

    //竞技场排名
    unsigned short              _usArenaRank;           //竞技场排名
    short                       _shWinningStreak;       //连胜次数

    //任务
    CUserTaskData               _stUserTaskData;

    //日常任务
    CDailyTaskUserData          _stUserDailyTaskData;

    //副本信息
    CInstanceData               _stInstanceData;

    //精力
    CUserEnergy                 _stUserEnergy;

    //宠物
    CPetData                    _stUserPetData;

    //vip
    CVipData                    _stVipData;

    //拍卖会
    CAuctionUserData            _stUserAuctionData;

    //黄钻礼包领取状态
    CYellowGiftData             _stYellowGiftData;

    //玩家冻结数据
    CFreezeData                 _stFreezeData;

    //魔晶潜能等级
    unsigned char               _ucCrystalPotenLevel;

    //魔晶潜能经验
    int  _iCrystalPotenExp;

    //蓝钻礼包领取状态
    CBlueGiftData               _stBlueGiftData;

    unsigned int _uiActStatus;
};

BEGIN_CODE_CONVERT(CPlayerBaseInfo)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_sUserToken)
CODE_CONVERT(_ucIsInited)
CODE_CONVERT(_sRoleName)
CODE_CONVERT(_ucIsMale)
CODE_CONVERT(_ucCareer)
CODE_CONVERT(_ucAcademy)

CODE_CONVERT(_iTotalOnlineTime)
CODE_CONVERT(_iDefTotalOnlineTime)
CODE_CONVERT(_iDefendValidInfo)
CODE_CONVERT(_iOnlineTimeSinceReg)

CODE_CONVERT(_uiMapID)
CODE_CONVERT(_usXPos)
CODE_CONVERT(_usYPos)
CODE_CONVERT(_shLevel)
CODE_CONVERT(_i64NowExp)
CODE_CONVERT(_iLevelUpTime)
CODE_CONVERT(_shActiveValue)

CODE_CONVERT(_uiExerciseValue)
CODE_CONVERT(_aucPassiveSkillLevel)
CODE_CONVERT(_aucTrainingCampRound)

CODE_CONVERT(_chVipLevel)
CODE_CONVERT(_iGold)
CODE_CONVERT(_i64Silver)
CODE_CONVERT(_iRomany)
CODE_CONVERT(_iFateForce)
CODE_CONVERT(_iHunli)

CODE_CONVERT(_ucGloryLevel)
CODE_CONVERT(_usGloryLevelUpExp)
CODE_CONVERT(_shNowGloryExp)
CODE_CONVERT(_auiGloryStats)

CODE_CONVERT(_usArenaRank)
CODE_CONVERT(_shWinningStreak)

CODE_CONVERT(_stUserTaskData)

CODE_CONVERT(_stInstanceData)

CODE_CONVERT(_stUserEnergy)
CODE_CONVERT(_stUserDailyTaskData)
CODE_CONVERT(_stUserPetData)
CODE_CONVERT(_stVipData)
CODE_CONVERT(_stUserAuctionData)

CODE_CONVERT(_stYellowGiftData)

CODE_CONVERT(_stFreezeData)

CODE_CONVERT(_ucCrystalPotenLevel)
CODE_CONVERT(_iCrystalPotenExp)

CODE_CONVERT(_stBlueGiftData)
CODE_CONVERT(_uiActStatus)
END_CODE_CONVERT(CPlayerBaseInfo)

//////////////////////////////////////////////////////////////////////////
class CPlayerEquipData
{
public:
    CPlayerEquipData(int iPos, int iEquipID)
        :_iPos(iPos), _iEquipID(iEquipID)
    {

    }

    CPlayerEquipData()
    {

    }

    int _iPos;
    int _iEquipID;
};

typedef CTLib::CTArray<CPlayerEquipData, MAX_PARTNER_EQUIP_NUM> T_EQUIP_DATA;

class CPlayerEquip : public CTCodeObject
{
public:
    CPlayerEquip()
    {
        Clear();
    }

    void Clear()
    {
        _auiPlayerEquip.m_iUsedCount = _auiPlayerEquip.GetCount();
        for (int i = 0; i < _auiPlayerEquip.Size(); ++i)
        {
            _auiPlayerEquip[i] = 0;
        }
    }
    void Clean()//注意二者区别
    {
        _auiPlayerEquip.Clear();
    }

    bool IsSizeValid()
    {
        return (_auiPlayerEquip.Size() == PLAYER_EQUIP_POS_MAX);
    }

    bool IsAllClear()
    {
        if (!IsSizeValid())
        {
            return false;
        }
        for (int i = 0; i < _auiPlayerEquip.Size(); ++i)
        {
            if (_auiPlayerEquip[i] != 0)
            {
                return false;
            }
        }

        return true;
    }

    int GetEquipList(T_EQUIP_DATA& astEquipList)
    {
        if (!IsSizeValid())
        {
            return ERROR_EQUIP_DATA_NO_INIT;
        }

        astEquipList.Clear();

        for (int i = 0; i <_auiPlayerEquip.Size() ; ++i)
        {
            if (_auiPlayerEquip[i] > 0)
            {
                astEquipList.AddOneItem(CPlayerEquipData(i + 1, _auiPlayerEquip[i]));
            }
        }
        return 0;
    }

    int GetEquip(unsigned int& uiEquipID, int iPos)
    {
        if (!IsSizeValid())
        {
            return ERROR_EQUIP_DATA_NO_INIT;
        }
        if (iPos < PLAYER_EQUIP_POS_MIN || iPos > PLAYER_EQUIP_POS_MAX)
        {
            return ERROR_EQUIP_UNKNOW_POS;
        }

        uiEquipID = _auiPlayerEquip[iPos - 1];

        return 0;
    }

    int SetEquip(unsigned int uiEquipID, int iPos)
    {
        if (!IsSizeValid())
        {
            return ERROR_EQUIP_DATA_NO_INIT;
        }
        if (iPos < PLAYER_EQUIP_POS_MIN || iPos > PLAYER_EQUIP_POS_MAX)
        {
            return ERROR_EQUIP_UNKNOW_POS;
        }

        _auiPlayerEquip[iPos - 1] = uiEquipID;

        return 0;
    }


public:

    CTLib::CTArray<unsigned int, PLAYER_EQUIP_POS_MAX> _auiPlayerEquip;

};

BEGIN_CODE_CONVERT(CPlayerEquip)
CODE_CONVERT(_auiPlayerEquip)
END_CODE_CONVERT(CPlayerEquip)


class CPartnerEquip : public CTCodeObject
{
public:
    CPartnerEquip()
    {
        Clear();
    }

    void Clear()
    {
        _auiPartnerEquip.m_iUsedCount = PARTNER_EQUIP_POS_MAX;
        for (int i = 0; i < _auiPartnerEquip.Size(); ++i)
        {
            _auiPartnerEquip[i] = 0;
        }
    }

    bool IsSizeValid()
    {
        return (_auiPartnerEquip.Size() == PARTNER_EQUIP_POS_MAX);
    }

    bool IsAllClear()
    {
        if (!IsSizeValid())
        {
            return false;
        }
        for (int i = 0; i < _auiPartnerEquip.Size(); ++i)
        {
            if (_auiPartnerEquip[i] != 0)
            {
                return false;
            }
        }

        return true;
    }
    int GetEquipList(T_EQUIP_DATA& astEquipList)
    {
        if (!IsSizeValid())
        {
            return ERROR_EQUIP_DATA_NO_INIT;
        }

        astEquipList.Clear();

        for (int i = 0; i <_auiPartnerEquip.Size() ; ++i)
        {
            if (_auiPartnerEquip[i] > 0)
            {
                astEquipList.AddOneItem(CPlayerEquipData(i + 1, _auiPartnerEquip[i]));
            }
        }
        return 0;
    }

    int GetEquip(unsigned int& uiEquipID, int iPos)
    {
        if (!IsSizeValid())
        {
            return ERROR_EQUIP_DATA_NO_INIT;
        }
        if (iPos < PARTNER_EQUIP_POS_MIN || iPos > PARTNER_EQUIP_POS_MAX)
        {
            return ERROR_EQUIP_UNKNOW_POS;
        }

        uiEquipID = _auiPartnerEquip[iPos - 1];

        return 0;
    }

    int SetEquip(unsigned int uiEquipID, int iPos)
    {
        if (!IsSizeValid())
        {
            return ERROR_EQUIP_DATA_NO_INIT;
        }
        if (iPos < PARTNER_EQUIP_POS_MIN || iPos > PARTNER_EQUIP_POS_MAX)
        {
            return ERROR_EQUIP_UNKNOW_POS;
        }

        _auiPartnerEquip[iPos - 1] = uiEquipID;

        return 0;
    }


public:

    CTLib::CTArray<unsigned int, PARTNER_EQUIP_POS_MAX> _auiPartnerEquip;

};

BEGIN_CODE_CONVERT(CPartnerEquip)
CODE_CONVERT(_auiPartnerEquip)
END_CODE_CONVERT(CPartnerEquip)


class CPlayerWareCard : public CTCodeObject
{
public:
    CPlayerWareCard()
    {
        _astPlayerCard.m_iUsedCount = _astPlayerCard.GetCount();

        for (int i = 0; i < _astPlayerCard.Size(); ++i)
        {
            _astPlayerCard[i] = 0;
        }
    }

    bool HasCard()
    {
        for (int i = 0; i < _astPlayerCard.Size(); ++i)
        {
            if (_astPlayerCard[i] != 0)
            {
                return true;
            }
        }

        return false;
    }

    int CanWareCardCount(unsigned short usRoleLevel) const
    {
        if (usRoleLevel < 20)
        {
            return 0;
        }
        else if (usRoleLevel < 30)
        {
            return 2;
        }
        else if (usRoleLevel < 40)
        {
            return 3;
        }
        else if (usRoleLevel < 50)
        {
            return 4;
        }
        else if (usRoleLevel < 60)
        {
            return 5;
        }
        else if (usRoleLevel < 70)
        {
            return 6;
        }
        else if (usRoleLevel < 80)
        {
            return 7;
        }
        else if (usRoleLevel >= 80)
        {
            return 8;
        }
        else
        {
            return 0;
        }
    }

    bool IsCanWare(unsigned short usRoleLevel, unsigned char ucPos) const
    {
        return CanWareCardCount(usRoleLevel) > ucPos;
    }

    bool IsWare(unsigned char ucPos)
    {
        if (ucPos >= MAX_CARD_COUNT_PER_ROLE)
        {
            return false;
        }

        return _astPlayerCard[ucPos] != 0;
    }

    int GetCardByPos(unsigned char ucPos, unsigned int& uiCardID)
    {
        if (ucPos >= MAX_CARD_COUNT_PER_ROLE)
        {
            return ERROR_CARD_WARE_POS;
        }

        uiCardID = _astPlayerCard[ucPos];
        return 0;
    }

    int TakeOff(unsigned char ucPos)
    {
        if (ucPos >= MAX_CARD_COUNT_PER_ROLE)
        {
            return ERROR_CARD_WARE_POS;
        }

        if (_astPlayerCard[ucPos] == 0)
        {
            return ERROR_CARD_NOT_WARE;
        }

        _astPlayerCard[ucPos] = 0;
        return 0;
    }

    int Ware(unsigned char ucPos, unsigned int uiCardID)
    {
        if (ucPos >= MAX_CARD_COUNT_PER_ROLE)
        {
            return ERROR_CARD_WARE_POS;
        }

        if (_astPlayerCard[ucPos] != 0)
        {
            return ERROR_CARD_HAS_WARE;
        }

        _astPlayerCard[ucPos] = uiCardID;
        return 0;
    }

public:
    CTLib::CTArray<unsigned int, MAX_CARD_COUNT_PER_ROLE> _astPlayerCard;
};

BEGIN_CODE_CONVERT(CPlayerWareCard)
CODE_CONVERT(_astPlayerCard)
END_CODE_CONVERT(CPlayerWareCard)

//命运漩涡
class CCardVortex : public CTCodeObject
{
public:
    CCardVortex()
    {
        _usLevel = 0;
        _iTotalFateForce = 0;
    }

    bool HasVortex()
    {
        return (_usLevel != 0 || _iTotalFateForce != 0);
    }

public:
    unsigned short _usLevel;            //当前等级
    int            _iTotalFateForce;    //命运漩涡总量
};

BEGIN_CODE_CONVERT(CCardVortex)
CODE_CONVERT(_usLevel)
CODE_CONVERT(_iTotalFateForce)
END_CODE_CONVERT(CCardVortex)


class CSingleDrug : public CTCodeObject
{
public:
    CSingleDrug()
    {
        Clear();
    }

    void Clear()
    {
        _shCapacity = 0;
    }

    //是否进入到了提纯阶段
    bool IsSyntheFull ()
    {
        return (_shCapacity < MAX_DRUG_CAPACITY) ? false : true;
    }

    //是否提纯满级
    bool IsPurifyFull ()
    {
        int iStage = GetPurifyStage();
        return (iStage == MAX_DRUG_PURIFY_LEVEL) ? true : false;
    }

    int GetPurifyStage ()
    {
        if (_shCapacity <= MAX_DRUG_CAPACITY)
        {
            return 0;
        }
        else
        {
            return ((_shCapacity - MAX_DRUG_CAPACITY)/100);
        }
    }

    void AddPurify (short  shToAddValue)
    {
        _shCapacity += shToAddValue;
        if (IsPurifyFull())
        {
            _shCapacity = MAX_PURIFY_PER_LEVEL * MAX_DRUG_PURIFY_LEVEL + MAX_DRUG_CAPACITY ;
        }
    }

    short          _shCapacity;   //小于100是合成阶段, [0, 800]
};
BEGIN_CODE_CONVERT(CSingleDrug)
CODE_CONVERT(_shCapacity)
END_CODE_CONVERT(CSingleDrug)


class CDrugData : public CTCodeObject
{
public:
    CDrugData()
    {
        Clear();
    }

    void Clear()
    {
        _astDrugData.m_iUsedCount = MAX_DRUG_CONFIG_ID;
        for (int i = 0; i < _astDrugData.Size(); i++)
        {
            _astDrugData[i].Clear();
        }

        _ucInheritFlag = 0;
    }

    bool CanInherit ()
    {
        return (0 == (_ucInheritFlag & 1) ? true : false);
    }

    bool CanBeInherit ()
    {
        return (0 == (_ucInheritFlag & 2) ? true : false);
    }

    void SetInherit ()
    {
        _ucInheritFlag |=  1;
    }

    void SetBeInherit ()
    {
        _ucInheritFlag |=  2;
    }

    CTArray<CSingleDrug, MAX_DRUG_CONFIG_ID> _astDrugData;
    unsigned char _ucInheritFlag;
};
BEGIN_CODE_CONVERT(CDrugData)
CODE_CONVERT(_astDrugData)
CODE_CONVERT(_ucInheritFlag)
END_CODE_CONVERT(CDrugData)

class CPartnerActData : public CTCodeObject
{
public:
    CPartnerActData()
    {
        _shResID = 0;
        _shLevel = 0;
        _iFavor = 0;
        _i64Exp = 0;

        _stEquip.Clear();
        _stDrugData.Clear();
    }

public:
    short               _shResID;           //资源ID
    short               _shLevel;           //等级
    int                 _iFavor;            //关系值
    int64               _i64Exp;            //经验

    CPartnerEquip       _stEquip;           //装备
    CPlayerWareCard     _stPlayerWareCard;  //卡片
    CCardVortex         _stCardVortex;      //命运漩涡
    CDrugData           _stDrugData;        //魔药
};

BEGIN_CODE_CONVERT(CPartnerActData)
CODE_CONVERT(_shResID)
CODE_CONVERT(_shLevel)
CODE_CONVERT(_iFavor)
CODE_CONVERT(_i64Exp)
CODE_CONVERT(_stEquip)
CODE_CONVERT(_stPlayerWareCard)
CODE_CONVERT(_stCardVortex)
CODE_CONVERT(_stDrugData)
END_CODE_CONVERT(CPartnerActData)

class CPartnerListData : public CTCodeObject
{
public:
    CPartnerListData()
    {
        _shResID = 0;
        _shLevel = 0;
        _iFavor = 0;
        _i64Exp = 0;
    }

public:
    short               _shResID;
    short               _shLevel;
    int                 _iFavor;
    int64               _i64Exp;

    CDrugData           _stDrugData;
};

BEGIN_CODE_CONVERT(CPartnerListData)
CODE_CONVERT(_shResID)
CODE_CONVERT(_shLevel)
CODE_CONVERT(_iFavor)
CODE_CONVERT(_i64Exp)
CODE_CONVERT(_stDrugData)
END_CODE_CONVERT(CPartnerListData)

class CPartnerData : public CTCodeObject
{
public:
    CPartnerData()
    {
        Clear();
    }

    void Clear()
    {
        _astActData.Clear();
    }

    int DelActData(short shResID)
    {
        for (int i = 0; i < _astActData.Size(); )
        {
            if (shResID == _astActData[i]._shResID)
            {
                int iRet = _astActData.DelOneItem(i);
                if (iRet < 0)
                {
                    return iRet;
                }
            }
            else
            {
                ++i;
            }
        }

        return 0;
    }

    int FindActData(short shResID)
    {
        for (int i = 0; i < _astActData.Size(); ++i)
        {
            if (shResID == _astActData[i]._shResID)
            {
                return i;
            }
        }

        return -1;
    }

    CPartnerActData& GetPartnerActData(int iIndex) {return _astActData[iIndex];}

    int GetEquip(short shResID, unsigned int& uiEquip, int iPos)
    {
        int iIndex = FindActData(shResID);
        if (iIndex < 0)
        {
            return ERROR_PARTNER_NOT_IN_ACT;
        }
        CPartnerActData& stActData = GetPartnerActData(iIndex);

        int iRet = stActData._stEquip.GetEquip(uiEquip, iPos);
        CT_RETURN(iRet);

        return 0;
    }

    int GetEquipList(short shResID, T_EQUIP_DATA& astEquipList)
    {
        int iIndex = FindActData(shResID);
        if (iIndex < 0)
        {
            return ERROR_PARTNER_NOT_IN_ACT;
        }
        CPartnerActData& stActData = GetPartnerActData(iIndex);

        return stActData._stEquip.GetEquipList(astEquipList);
    }

    int  WearEquip(short shResID, unsigned int uiEquipID, int iPos)
    {
        if (uiEquipID == 0)
        {
            return ERROR_EQUIP_UNKNOW_ID;
        }

        int iIndex = FindActData(shResID);
        if (iIndex < 0)
        {
            return ERROR_PARTNER_NOT_IN_ACT;
        }
        CPartnerActData& stActData = GetPartnerActData(iIndex);

        unsigned int uiEquip;
        int iRet = stActData._stEquip.GetEquip(uiEquip, iPos);
        CT_RETURN(iRet);

        if (uiEquip != 0)
        {
            return ERROR_EQUIP_ADD_DUPLICATE;
        }

        iRet = stActData._stEquip.SetEquip(uiEquipID, iPos);
        CT_RETURN(iRet);

        return 0;
    }

    int  TakeOffEquip(short shResID, unsigned int uiEquipID, int iPos)
    {
        if (uiEquipID == 0)
        {
            return ERROR_EQUIP_UNKNOW_ID;
        }

        int iIndex = FindActData(shResID);
        if (iIndex < 0)
        {
            return ERROR_PARTNER_NOT_IN_ACT;
        }
        CPartnerActData& stActData = GetPartnerActData(iIndex);

        unsigned int uiEquip;
        int iRet = stActData._stEquip.GetEquip(uiEquip, iPos);
        CT_RETURN(iRet);

        if (uiEquip == 0)
        {
            return ERROR_EQUIP_ALREADY_TAKEOFF;
        }
        if (uiEquip != uiEquipID)
        {
            return ERROR_EQUIP_UNKNOW_ID;
        }

        iRet = stActData._stEquip.SetEquip(0, iPos);
        CT_RETURN(iRet);

        return 0;
    }

    CTArray<CPartnerActData, MAX_PARTNER_ACT_COUNT> _astActData;
};

BEGIN_CODE_CONVERT(CPartnerData)
CODE_CONVERT(_astActData)
END_CODE_CONVERT(CPartnerData)

enum
{
    STORAGE_POS_NOT_OCCUPIED = 0xFFFF,
};
//////////////////////////////////////////////////////////////////////////
class StorageItemData : public CTCodeObject
{
public:
    StorageItemData()
    {
        _ucIsInBag = true;
        Clear();
    }

    void Clear ()
    {
        _ucItemType = ITEM_TYPE_NULL;
        _uiItemID = 0;
        _shItemCount = 0;
        _usStorePos = STORAGE_POS_NOT_OCCUPIED;
        _iInvalidTime = 0;
    }


    bool IsEmpty()
    {
        return  (0 == _shItemCount);
    }

public:
    unsigned char _ucItemType;
    unsigned int  _uiItemID;
    short           _shItemCount;
    unsigned char   _ucIsInBag;
    unsigned short  _usStorePos;
    int      _iInvalidTime;
};

BEGIN_CODE_CONVERT(StorageItemData)
CODE_CONVERT(_ucItemType)
CODE_CONVERT(_uiItemID)
CODE_CONVERT(_shItemCount)
CODE_CONVERT(_ucIsInBag)
CODE_CONVERT(_usStorePos)
CODE_CONVERT(_iInvalidTime)
END_CODE_CONVERT(StorageItemData)


class StorageData : public CTCodeObject
{
public:
    StorageData()
    {
        _shMaxBagGridCount = SYS_DEFAULT_GRID_NUM_BAG;
        _shMaxWareHouseGridCount = SYS_DEFAULT_GRID_NUM_WAREHOUSE;
        Clear();
    }

    void Clear()
    {
        _astGridData.m_iUsedCount = MAX_BAG_GRID_COUNT + MAX_WAREHOUSE_GRID_COUNT;
        ClearBag();
        ClearWare();
        _astCommGrid.Clear();
    }

    void ClearBag()
    {
        for (int i = 0; i < MAX_BAG_GRID_COUNT; i++)
        {
            _astGridData[i].Clear();
            _astGridData[i]._ucIsInBag = true;
        }
    }

    void ClearWare()
    {
        for (int i = 0; i < MAX_WAREHOUSE_GRID_COUNT; i++)
        {
            _astGridData[i + MAX_BAG_GRID_COUNT].Clear();
            _astGridData[i + MAX_BAG_GRID_COUNT]._ucIsInBag = false;
        }
    }

    short _shMaxBagGridCount;           //背包可用格子数(=系统缺省打开的+用户手工解锁的)
    short _shMaxWareHouseGridCount;     //仓库可用格子数(=系统缺省打开的+用户手工解锁的)
    CTArray<StorageItemData, MAX_BAG_GRID_COUNT + MAX_WAREHOUSE_GRID_COUNT> _astGridData;
    CTArray<CDropItemData, MAX_COMM_GRID_COUNT> _astCommGrid;
};

BEGIN_CODE_CONVERT(StorageData)
CODE_CONVERT(_shMaxBagGridCount)
CODE_CONVERT(_shMaxWareHouseGridCount)
CODE_CONVERT(_astGridData)
CODE_CONVERT(_astCommGrid)
END_CODE_CONVERT(StorageData)

//装备洗练和祝福
class CEquipRefineAndBless : public CTCodeObject
{
public:
    CEquipRefineAndBless()
    {

    }

public:
    
};

#define INVALID_PARTNER_ID  0xFFFFFFFF
typedef CTArray<unsigned char, 10> T_EQUIP_REFINE_AND_BLESS;
class CSingleEquip : public CTCodeObject
{
public:

    CSingleEquip()
    {
        Clear();
    }

    void Clear ()
    {
        _uiEquipID = 0;
        _usEquipConfigID = 0;
        _usStrengthenLevel = 1;
        _aucCrystalID.m_iUsedCount = MAX_EQUIP_CRYSTAL_NUM;
        for (int i = 0; i < MAX_EQUIP_CRYSTAL_NUM; i++)
        {
            _aucCrystalID[i] = 0;
        }

        _uiPartnerId = INVALID_PARTNER_ID;

        _stRefineAndBlessStats.m_iUsedCount = _stRefineAndBlessStats.GetCount();
        for (int i = 0; i < _stRefineAndBlessStats.Size(); ++i)
        {
            _stRefineAndBlessStats[i] = 0;
        }
    }

    //被穿上返回真, 否则为假
    bool IsWeared ()
    {
        return (INVALID_PARTNER_ID != _uiPartnerId);
    }

    virtual ~CSingleEquip()
    {
    }

    //洗练属性是否存在
    bool HasRefineAttr(unsigned char ucAttrID)
    {
        for (int i = 0; i < MAX_EQUIP_REFINE_ATTR_PER_EQUIP; ++i)
        {
            if (_stRefineAndBlessStats[i] == 0)
            {
                break;
            }

            if (_stRefineAndBlessStats[i] / 10 == ucAttrID)
            {
                return true;
            }
        }

        return false;
    }

public:
    unsigned int   _uiEquipID;          //装备ID，每用户唯一
    unsigned short _usEquipConfigID;    //装备配置ID
    unsigned short _usStrengthenLevel;   //强化等级
    CTArray<unsigned char, MAX_EQUIP_CRYSTAL_NUM> _aucCrystalID;  //已镶嵌的魔晶
    unsigned int  _uiPartnerId;         //佩戴装备的伙伴ID

    //如果是洗练，前5个表示在使用的属性，后5个表示还未被采用的属性
    //如果是祝福，第一个表示祝福了哪4种属性，第二个表示祝福等级， 属性顺序：智力、体力、力量、敏捷
    T_EQUIP_REFINE_AND_BLESS _stRefineAndBlessStats;            //装备洗练和祝福
};
BEGIN_CODE_CONVERT(CSingleEquip)
CODE_CONVERT(_uiEquipID)
CODE_CONVERT(_usEquipConfigID)
CODE_CONVERT(_usStrengthenLevel)
CODE_CONVERT(_aucCrystalID)
CODE_CONVERT(_uiPartnerId)
CODE_CONVERT(_stRefineAndBlessStats)
END_CODE_CONVERT(CSingleEquip)

class CEquipData : public CTCodeObject
{
public:
    CEquipData()
    {
        Clear();
        _iBlessPoint = 0;
    }

    void Clear()
    {
        _uiEquipSeqId = 0;
        for (int i = 0; i < MAX_EQUIP_COUNT_PER_USER; i++)
        {
            _astEquipData[i].Clear();
        }
        _astEquipData.Clear();
    }

public:
    unsigned int      _uiEquipSeqId;    //分配装备ID 的序列号
    CTLib::CTArray<CSingleEquip, MAX_EQUIP_COUNT_PER_USER> _astEquipData; //用户的装备
    int               _iBlessPoint;     //祝福点
};
BEGIN_CODE_CONVERT(CEquipData)
CODE_CONVERT(_uiEquipSeqId)
CODE_CONVERT(_astEquipData)
CODE_CONVERT(_iBlessPoint)
END_CODE_CONVERT(CEquipData)

//////////////////////////////////////////////////////////////////////////
class CPlayerDBSkill : public CTCodeObject
{
public:
    CPlayerDBSkill()
    {
        Clear();
    }

    virtual ~CPlayerDBSkill()
    {

    }

    void Clear ()
    {
        _uiMagicSkillID = 0;
    }

public:
    unsigned int  _uiMagicSkillID;
};

BEGIN_CODE_CONVERT(CPlayerDBSkill)
CODE_CONVERT(_uiMagicSkillID)
END_CODE_CONVERT(CPlayerDBSkill)

//////////////////////////////////////////////////////////////////////////
class CMatrixUnit : public CTCodeObject
{
public:
    CMatrixUnit()
    {
        Clear();
    }

    virtual ~CMatrixUnit()
    {
    }

    void Clear ()
    {
        _chType = 0;
        _chPos = 0;
        _uiID = 0;
    }

public:
    char            _chType;        //类型 1 主角 2 伙伴
    char            _chPos;         //站位下标
    unsigned int    _uiID;          //类型为主角时 保存主角GID 类型为伙伴时 保存伙伴配置ID
};

BEGIN_CODE_CONVERT(CMatrixUnit)
CODE_CONVERT(_chType)
CODE_CONVERT(_chPos)
CODE_CONVERT(_uiID)
END_CODE_CONVERT(CMatrixUnit)

class CMatrixList : public CTCodeObject
{
public:
    CMatrixList()
    {
        Clear();
    }

    virtual ~CMatrixList()
    {
    }

    void Clear()
    {
        _uiPosMask = 0;
        _achCareerCount.Clear();
        _astMatrixList.Clear();
    }

public:
    unsigned int _uiPosMask;            //站位的掩码
    CTLib::CTArray<char, CAREER_END> _achCareerCount;
    CTLib::CTArray<CMatrixUnit, MAX_MATRIX_UNIT_COUNT> _astMatrixList;
};

BEGIN_CODE_CONVERT(CMatrixList)
CODE_CONVERT(_uiPosMask)
CODE_CONVERT(_achCareerCount)
CODE_CONVERT(_astMatrixList)
END_CODE_CONVERT(CMatrixList)

class CPlayerMatrix : public CTCodeObject
{
public:
    CPlayerMatrix()
    {
        Clear();
    }

    virtual ~CPlayerMatrix()
    {
    }

    void Clear ()
    {
        _chMainMatrix = -1;
        _astMatrixData.Clear();
    }

public:
    char _chMainMatrix; //主阵形
    CTLib::CTArray<CMatrixList, MAX_MATRIX_LIST_COUNT>  _astMatrixData;
};

BEGIN_CODE_CONVERT(CPlayerMatrix)
CODE_CONVERT(_chMainMatrix)
CODE_CONVERT(_astMatrixData)
END_CODE_CONVERT(CPlayerMatrix)


class CUserDivineData : public CTCodeObject
{
public:
    CUserDivineData()
    {
        Clear();
    }

    void Clear()
    {
        ucCardPos = 0;
        _iSilver = 0;
        _shFateForce = 0;
        _cGreenCard = 0;
        _cBlueCard = 0;
        _cPurpleCard = 0;
        _cGoldCard = 0;
        _cSoulCard = 0;
        _cRomany = 0;
        _ucTurnOverCardCount = 0;
        _ausGoldDivineCards.Clear();
        _stHasGoldDivineCount.SetDefault(0);
    }

    bool IsFull()
    {
        if (_shFateForce >= 1000)
        {
            return true;
        }

        if (_cGreenCard >= 60)
        {
            return true;
        }

        if (_cBlueCard >= 60)
        {
            return true;
        }

        if (_cPurpleCard >= 60)
        {
            return true;
        }

        if (_cGoldCard >= 60)
        {
            return true;
        }

        if (_cSoulCard >= 60)
        {
            return true;
        }

        if (_cRomany >= 60)
        {
            return true;
        }

        return false;
    }


public:
    unsigned char ucCardPos;
    int _iSilver;
    short _shFateForce;
    char _cGreenCard;
    char _cBlueCard;
    char _cPurpleCard;
    char _cGoldCard;
    char _cSoulCard;
    char _cRomany;
    unsigned char _ucTurnOverCardCount; //翻牌次数，只用于“要求玩家的前2次占卜是必然成功的”

    CTLib::CTArray<unsigned short, MAX_CARD_GOLD_DIVINE_CARD_COUNT> _ausGoldDivineCards; //金币占卜卡片暂存格
    CDailyReflushUShort _stHasGoldDivineCount;          //已经占卜的次数
};

BEGIN_CODE_CONVERT(CUserDivineData)
CODE_CONVERT(ucCardPos)
CODE_CONVERT(_iSilver)
CODE_CONVERT(_shFateForce)
CODE_CONVERT(_cGreenCard)
CODE_CONVERT(_cBlueCard)
CODE_CONVERT(_cPurpleCard)
CODE_CONVERT(_cGoldCard)
CODE_CONVERT(_cSoulCard)
CODE_CONVERT(_cRomany)
CODE_CONVERT(_ucTurnOverCardCount)
CODE_CONVERT(_ausGoldDivineCards)
CODE_CONVERT(_stHasGoldDivineCount)
END_CODE_CONVERT(CUserDivineData)

class CSingleCardData : public CTCodeObject
{
public:
    CSingleCardData()
    {

    }

    void Clear()
    {
        _uiCardID = 0;
        _usCardConfigID = 0;
        _usLevel = 0;
        _iNowExp = 0;

        _ucCanWare = 0;
        _ucIsWare = 0;
        _iWareRoleID = 0;
    }

public:
    unsigned int _uiCardID;
    unsigned short _usCardConfigID;
    unsigned short _usLevel;
    int _iNowExp;

    unsigned short _usPos;   //在背包中所在的位置或者在身上的位置

    unsigned char _ucCanWare;   //是否可穿
    unsigned char _ucIsWare;    //是否已穿
    int _iWareRoleID;           //穿戴者，0就是主角
};

BEGIN_CODE_CONVERT(CSingleCardData)
CODE_CONVERT(_uiCardID)
CODE_CONVERT(_usCardConfigID)
CODE_CONVERT(_usLevel)
CODE_CONVERT(_iNowExp)
CODE_CONVERT(_usPos)
CODE_CONVERT(_ucCanWare)
CODE_CONVERT(_ucIsWare)
CODE_CONVERT(_iWareRoleID)
END_CODE_CONVERT(CSingleCardData)

class CUserCardData : public CTCodeObject
{
public:
    CUserCardData()
        :_iNowCardID(0)
    {
        Clear();
    }

    void Clear()
    {
        _astCardDatas.Clear();
    }

    int _iNowCardID;            //当前卡片ID，自增
    CTLib::CTArray<CSingleCardData, MAX_CARD_COUNT> _astCardDatas;
};

BEGIN_CODE_CONVERT(CUserCardData)
CODE_CONVERT(_iNowCardID)
CODE_CONVERT(_astCardDatas)
END_CODE_CONVERT(CUserCardData)

//////////////////////////////////////////////////////////////////////////

class CBattleTitle : public CTCodeObject
{
public:
    CBattleTitle()
    {

    }

public:
    unsigned int _uiAtkGID;
    CTSizeString<ROLENAME_LEN> _szAtkName;
    unsigned int _uiDefGID;
    CTSizeString<ROLENAME_LEN> _szDefName;
    unsigned char _ucIsAtkWin;
    int _iBattleTime;
    T_VIDEO_KEY szVideoKey;

    int _iAtkRank;
    int _iDefRank;

    int _iAtkOrgRank;
    int _iDefOrgRank;
};

BEGIN_CODE_CONVERT(CBattleTitle)
CODE_CONVERT(_uiAtkGID)
CODE_CONVERT(_szAtkName)
CODE_CONVERT(_uiDefGID)
CODE_CONVERT(_szDefName)
CODE_CONVERT(_ucIsAtkWin)
CODE_CONVERT(_iBattleTime)
CODE_CONVERT(szVideoKey)
CODE_CONVERT(_iAtkRank)
CODE_CONVERT(_iDefRank)
CODE_CONVERT(_iAtkOrgRank)
CODE_CONVERT(_iDefOrgRank)
END_CODE_CONVERT(CBattleTitle)

//竞技场排名
class CArenaRank : public CTCodeObject
{
public:
    CArenaRank()
    {
        Clear();
    }

    virtual ~CArenaRank()
    {
    }

    void Clear()
    {
        _uiGID = 0;
        _iMaxRank = 0;
        _iBonusRank = 0;
        _iNowRank = 0;
        _iNowRankUpdateTime = 0;
        _iConWinCount = 0;
        _iLastWinTime = 0;
    }

    int Init(int iNowTime)
    {
        Clear();
        _iNowRankUpdateTime = iNowTime;

        return 0;
    }

    //下降一位
    int FallOne(int iLastAccountTime, int iNextAccountTime, int iNowTime)
    {
        return SetRank(_iNowRank + 1, iLastAccountTime, iNextAccountTime, iNowTime);
    }

    int GetRank() const
    {
        return _iNowRank;
    }

    int GetConWinCount(int iNowTime) const
    {
        /*
        if (IsSameRound(iNowTime, _iLastWinTime, DATA_RESET_SEC_OF_DAY))
        {
            return _iConWinCount;
        }
        */

        return _iConWinCount;
    }

    int SetRank(int iNowRank, int iLastAccountTime, int iNextAccountTime, int iNowTime)
    {
        if (iNowRank <= 0)
        {
            return RET_SYS_ERROR;
        }

        if (_iNowRankUpdateTime != 0
            && !IsSameRound(iNowTime, _iNowRankUpdateTime, iLastAccountTime))
        {
            _iBonusRank = _iNowRank;
        }

        _iBonusRank = GetBonusRank(iLastAccountTime, iNextAccountTime);
        _iNowRank = iNowRank;
        _iNowRankUpdateTime = iNowTime;

        if (_iMaxRank == 0)
        {
            _iMaxRank = iNowRank;
        }
        else
        {
            _iMaxRank = CT_MIN(_iMaxRank, iNowRank); //最高排名是排名最低的那个值
        }

        CT_TRACE(("ARENA: gid = %u, bonus_rank = %d, now_rank = %d", _uiGID, _iBonusRank, iNowRank));

        return 0;
    }

    int GetBonusRank(int iLastAccountTime, int iNextAccountTime)
    {
        if (_iNowRankUpdateTime == 0) //新用户
        {
            return 0;
        }

        if (_iNowRankUpdateTime >= iLastAccountTime
            && _iNowRankUpdateTime < iNextAccountTime)
        {
            return _iBonusRank;
        }

        if (_iNowRankUpdateTime >= iNextAccountTime) //这种可能性不大
        {
            return 0;
        }

        return _iNowRank;
    }

private:
    bool IsSameRound(int iTime1, int iTime2, int iLastAccountTime) const
    {
        int iTimeOffset = CTLib::CTTimeUtils::GetSecOfDay(iLastAccountTime);
        return CTTimeUtils::IsSameDay(iTime1, iTime2, iTimeOffset);
    }

public:
    unsigned int _uiGID;
    int _iMaxRank;               //历史最高排名

    int _iBonusRank;             //奖励的名次
    int _iNowRank;               //当前排名
    int _iNowRankUpdateTime;     //当前排名更新时间

    int _iConWinCount;              //连胜次数
    int _iLastWinTime;              //最后一次胜利时间
    int _iRankUpCount;              //累计排名提升次数
};

BEGIN_CODE_CONVERT(CArenaRank)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_iMaxRank)

CODE_CONVERT(_iBonusRank)
CODE_CONVERT(_iNowRank)
CODE_CONVERT(_iNowRankUpdateTime)

CODE_CONVERT(_iConWinCount)
CODE_CONVERT(_iLastWinTime)
CODE_CONVERT(_iRankUpCount)
END_CODE_CONVERT(CArenaRank)

//用来记录数据历史
class CDataHistory : public CTCodeObject
{
public:
    typedef CTLib::CTArray<int, ARENA_MAX_Rank_HISTORY_COUNT> T_DATA_HISTORY;

    CDataHistory()
    {
        Clear();
    }

    virtual ~CDataHistory()
    {

    }

    void Clear()
    {
        _iLastUpdateTime = 0;
        _aiDataHis.Clear();
    }

    int GetRecentHis()
    {
        if (_aiDataHis.Size() == 0)
        {
            return 0;
        }

        return _aiDataHis[_aiDataHis.Size() - 1];
    }

    int AddHis(int iData, int iNowTime)
    {
        if (IsSameGap(iNowTime, _iLastUpdateTime))
        {
            _aiDataHis[_aiDataHis.Size() - 1] = iData;
            return 0;
        }
        else if (_aiDataHis.Size() != _aiDataHis.GetCount())
        {
            _aiDataHis.AddOneItem(iData);
        }
        else
        {
            int iHisDays = GetGaps(iNowTime, _iLastUpdateTime);
            T_DATA_HISTORY stTmp;
            for (int i = iHisDays; i < _aiDataHis.Size(); ++i)
            {
                stTmp.AddOneItem(_aiDataHis[i]);
            }

            while(stTmp.Size() != stTmp.GetCount())
            {
                stTmp.AddOneItem(iData);
            }
            _aiDataHis = stTmp;
        }

        _iLastUpdateTime = iNowTime;
        return 0;
    }

private:
    bool IsSameGap(time_t tTime1, time_t tTime2)
    {
        return CTTimeUtils::IsSameDay(tTime1, tTime2);
    }

    int GetGaps(time_t tTime1, time_t tTime2)
    {
        return abs(tTime1 / 86400 - tTime2 / 86400);
    }

public:
    int _iLastUpdateTime;
    T_DATA_HISTORY _aiDataHis;
};

BEGIN_CODE_CONVERT(CDataHistory)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_aiDataHis)
END_CODE_CONVERT(CDataHistory)

//竞技场详细数据（除排名以外）
class CUserArenaData : public CTCodeObject
{
public:
    CUserArenaData()
    {
        Clear();
    }

    void Clear()
    {
        _uiGID = 0;

        _iLastGetBonusTime = 0;

        _iLastFightTime = 0;
        _iCanFreeFightCount = 0;
        _iCanFightTime = 0;

        _iCanFlushFightCount = 0;
        _iLastFlushTime = 0;

        _iBuyFightCount = 0;
        _iHasBuyFightCount = 0;
        _iLastBuyFightCountTime = 0;

        _iBuyFlushFightCount = 0;
        _iLastBuyFightCountTime = 0;

        stRankHis.Clear();

        _iLastGetVideoListTime = 0;
        _astVideoList.Clear();

        _szWinSay.Set("");

        _iBeenAtkDropToRank = 0;
        _iBeenAtkGID = 0;
    }

    int GetCanFightCount(int iNowTime) const
    {
        if (CTTimeUtils::IsSameDay(iNowTime, _iLastFightTime, DATA_RESET_SEC_OF_DAY))
        {
            return _iCanFreeFightCount + _iBuyFightCount;
        }

        return ARENA_MAX_FIGHT_COUNT_PER_DAY + _iBuyFightCount;
    }

    int SubFightCount(int iNowTime)
    {
        if (!CTTimeUtils::IsSameDay(iNowTime, _iLastFightTime, DATA_RESET_SEC_OF_DAY))
        {
            _iCanFreeFightCount = ARENA_MAX_FIGHT_COUNT_PER_DAY;
        }

        if (_iCanFreeFightCount > 0)
        {
            _iCanFreeFightCount--;
        }
        else if (_iBuyFightCount > 0)
        {
            _iBuyFightCount--;
        }

        _iLastFightTime = iNowTime;

        return 0;
    }

    int GetBuyFightCount(int iNowTime) const
    {
        if (CTTimeUtils::IsSameDay(iNowTime, _iLastBuyFightCountTime, DATA_RESET_SEC_OF_DAY))
        {
            return _iHasBuyFightCount;
        }

        return 0;
    }

    int GetBuyFlushFightCount(int iNowTime) const
    {
        if (CTTimeUtils::IsSameDay(iNowTime, _iLastBuyFlushFightCountTime, DATA_RESET_SEC_OF_DAY))
        {
            return _iBuyFlushFightCount;
        }

        return 0;
    }

public:
    unsigned int _uiGID;         //(不入库)

    int _iLastGetBonusTime;     //最后一次领取奖励时间

    int _iLastFightTime;        //最后一次主动发起战斗时间
    int _iCanFreeFightCount;        //还可以挑战的次数
    int _iCanFightTime;         //下次可挑战的时间

    int _iCanFlushFightCount;   //还可以刷新几次
    int _iLastFlushTime;        //最后一次刷新时间

    int _iHasBuyFightCount;        //已购买挑战次数
    int _iLastBuyFightCountTime; //最后一次购买的时间

    int _iBuyFlushFightCount;   //累计购买冷却时间刷新次数
    int _iLastBuyFlushFightCountTime; //最后一次购买冷却时间刷新的时间

    CDataHistory stRankHis;  //排名历史

    int _iLastGetVideoListTime;     //最后一次获取录像列表的时间
    CTLib::CTArray<CBattleTitle, ARENA_MAX_VIDEO_COUNT> _astVideoList;       //录像列表

    CTSizeString<ARENA_MAX_WIN_SAY_LEN> _szWinSay; //胜利宣言

    int _iBuyFightCount;        //累计购买挑战次数
    int _iBeenAtkDropToRank;    //被攻击掉落到N名
    int _iBeenAtkGID;           //最后一次被攻击且掉落名字时攻击者的GID
};

BEGIN_CODE_CONVERT(CUserArenaData)
CODE_CONVERT(_iLastGetBonusTime)

CODE_CONVERT(_iLastFightTime)
CODE_CONVERT(_iCanFreeFightCount)
CODE_CONVERT(_iCanFightTime)

CODE_CONVERT(_iCanFlushFightCount)
CODE_CONVERT(_iLastFlushTime)

CODE_CONVERT(_iHasBuyFightCount)
CODE_CONVERT(_iLastBuyFightCountTime)

CODE_CONVERT(_iBuyFlushFightCount)
CODE_CONVERT(_iLastBuyFlushFightCountTime)

CODE_CONVERT(stRankHis)

CODE_CONVERT(_iLastGetVideoListTime)
CODE_CONVERT(_astVideoList)

CODE_CONVERT(_szWinSay)
CODE_CONVERT(_iBeenAtkDropToRank)
CODE_CONVERT(_iBeenAtkGID)
END_CODE_CONVERT(CUserArenaData)

template<typename T, int COUNT>
class CTRankArray : public CTArray<T,COUNT>, public CTCodeObject
{
public:
    CTRankArray()
    {
    }

    virtual ~CTRankArray()
    {
    }

    virtual bool IsSame(T&, T&) const
    {
        return false;
    }

    // a > b, 返回大于0,　　a < b, 返回小于0
    virtual int CmpFunc(T & a, T & b) const
    {
        return 0;
    }

	/*
	更新以CTArray为基础的排名榜 支持数值正负变化
    声明一个CTRankArray实例时候需要在cpp文件中实现IsSame和CmpFunc
    iOld 表示更新前的排名 iNew 表示更新后的排名 都从0开始 -1表示不在榜中
	返回值：0
	*/
    int Update(T& t, int& iOld, int& iNew)
    {
        //支持数值正负变化后的更新

        bool bAdd = true;
        bool bSwap = false;

        iOld = -1;
        iNew = -1;

        T stSwap = t;
        T stTemp = t;

        for (int i = 0; i < CTArray<T,COUNT>::Size(); ++i)
        {
            if ((!bSwap && CmpFunc(stSwap, CTArray<T,COUNT>::m_astData[i]) > 0) ||
                (bSwap && CmpFunc(stSwap, CTArray<T,COUNT>::m_astData[i]) >= 0))
            {
                if (bSwap)
                {
                    if (IsSame(t, CTArray<T,COUNT>::m_astData[i]))//单元已在榜中但排名变前
                    {
                        bAdd = false;
                        iOld = i;
                        CTArray<T,COUNT>::m_astData[i] = stSwap;
                        break;
                    }
                    else
                    {
                        stTemp = CTArray<T,COUNT>::m_astData[i];
                        CTArray<T,COUNT>::m_astData[i] = stSwap;
                        stSwap = stTemp;
                    }
                }
                else
                {
                    if (IsSame(t, CTArray<T,COUNT>::m_astData[i]))//单元已在榜中但排名没变
                    {
                        bAdd = false;
                        iOld = i;
                        iNew = i;
                        CTArray<T,COUNT>::m_astData[i] = stSwap;
                        break;
                    }
                    else
                    {
                        bSwap = true;
                        iNew = i;
                        stTemp = CTArray<T,COUNT>::m_astData[i];
                        CTArray<T,COUNT>::m_astData[i] = stSwap;
                        stSwap = stTemp;
                    }
                }
            }
            else if (IsSame(t, CTArray<T,COUNT>::m_astData[i]))//单元已在榜中但排名变后
            {
                bAdd = false;
                iOld = i;
                CTArray<T,COUNT>::m_astData[i] = stSwap;

                for ( ; i + 1 < CTArray<T,COUNT>::Size(); ++i)
                {
                    if (CmpFunc(CTArray<T,COUNT>::m_astData[i], CTArray<T,COUNT>::m_astData[i+1]) < 0)
                    {
                        stTemp = CTArray<T,COUNT>::m_astData[i];
                        CTArray<T,COUNT>::m_astData[i] = CTArray<T,COUNT>::m_astData[i+1];
                        CTArray<T,COUNT>::m_astData[i+1] = stTemp;
                        iNew = i + 1;
                    }
                    else
                    {
                        break;
                    }
                }
    
                break;
            }
        }
    
        if (bAdd && CTArray<T,COUNT>::Size() < CTArray<T,COUNT>::GetCount())
        {
            if (iNew >= 0)
            {
                CTArray<T,COUNT>::AddOneItem(stSwap);
            }
            else
            {
                iNew = CTArray<T,COUNT>::AddOneItem(stSwap);
            }
        }
    
        return 0;
    }

    int Update(T& t)
    {
        int iTmp = 0;
        return Update(t, iTmp, iTmp);
    }

};

//魔界门数据
class CMagicDoorContriUnit : public CTCodeObject
{
public:
    CMagicDoorContriUnit()
    {
        Clear();
    }

    void Clear()
    {
        _uiGID = 0;
        _iCount = 0;
        _sRoleName.Set("");
    }

    unsigned int GetGID() const {return _uiGID;}
    int GetCount() const {return _iCount;}
    char* GetRoleName() const {return _sRoleName.Get();}

    void SetCount(int iVal){_iCount = iVal;}
    void SetGID(unsigned int uiVal){_uiGID = uiVal;}
    void SetRoleName(const char* pszName){_sRoleName.Set(pszName);}

public:
    unsigned int _uiGID;
    int _iCount;
    CTSizeString<ROLENAME_LEN> _sRoleName;
};
BEGIN_CODE_CONVERT(CMagicDoorContriUnit)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_iCount)
CODE_CONVERT(_sRoleName)
END_CODE_CONVERT(CMagicDoorContriUnit)

class CMagicDoorMonUnit : public CTCodeObject
{
public:
    CMagicDoorMonUnit()
    {
        Clear();
    }

    void Clear()
    {
        _chSpecMon = 0;
        _iNowHP = 0;
        _iMaxHP = 0;
    }

    int GetNowHP() const {return _iNowHP;}
    int GetMaxHP() const {return _iMaxHP;}
    char IsSpecialMon() const {return _chSpecMon;}

    void SetNowHP(int iVal) {_iNowHP = iVal;}
    void SetMaxHP(int iVal) {_iMaxHP = iVal;}
    void SetSpecMon(char chVal) {_chSpecMon = chVal;}

public:
    char _chSpecMon;
    int _iNowHP;
    int _iMaxHP;
};
BEGIN_CODE_CONVERT(CMagicDoorMonUnit)
CODE_CONVERT(_chSpecMon)
CODE_CONVERT(_iNowHP)
CODE_CONVERT(_iMaxHP)
END_CODE_CONVERT(CMagicDoorMonUnit)

class CMagicDoorData: public CTCodeObject
{
public:
    CMagicDoorData()
    {
        Clear();
    }

    void Clear()
    {
        _chNowLevel = 0;
        _chOpenLevel = 0;
        _chStatus = 0;
        _iExp = 0;
        _iOpenTime = 0;
        _iWorldLevel = 0;
        _stDailyCounts.Clear();
        _astContriList.Clear();
        _astMonsterList.Clear();
    }

public:
    char _chNowLevel;    //魔界门当前等级
    char _chOpenLevel;   //魔界门开启等级
    char _chStatus;   //魔界门当前状态，0：关闭，未开启，1:打开，开启状态，可以战斗
    int _iExp;        //当前魔界门经验
    int _iOpenTime;   //魔界门开启时间
    int _iWorldLevel; //世界等级

    CDailyReflushChar _stDailyCounts;    //每天魔界门的开启次数

    //魔界门充能次数排行前三名
    CTRankArray<CMagicDoorContriUnit, MAX_CONTRIBUTE_LIST> _astContriList; 
    CTLib::CTArray<CMagicDoorMonUnit, MAX_MAGIC_DOOR_BOSS_NUMS> _astMonsterList;
};
BEGIN_CODE_CONVERT(CMagicDoorData)
CODE_CONVERT(_chNowLevel)
CODE_CONVERT(_chOpenLevel)
CODE_CONVERT(_chStatus)
CODE_CONVERT(_iExp)
CODE_CONVERT(_iOpenTime)
CODE_CONVERT(_stDailyCounts)
CODE_CONVERT(_astContriList)
CODE_CONVERT(_astMonsterList)
CODE_CONVERT(_iWorldLevel)
END_CODE_CONVERT(CMagicDoorData)

class CClanMember : public CTCodeObject
{
public:
    CClanMember()
    {
        _uiGid = 0;
        _ucClanTitle = 0;
        _iTodayContri = 0;
        _iLastCalcTime = 0;
        _iAccumContri = 0;
    }

    unsigned int   _uiGid;  //用户GID
    unsigned char  _ucClanTitle;   //家族职位
    int   _iTodayContri;   //今日贡献度
    int   _iLastCalcTime;  //上次计算贡献度的时间
    int   _iAccumContri;  //在家族中累计获取的贡献度
};
BEGIN_CODE_CONVERT(CClanMember)
CODE_CONVERT(_uiGid)
CODE_CONVERT(_ucClanTitle)
CODE_CONVERT(_iTodayContri)
CODE_CONVERT(_iLastCalcTime)
CODE_CONVERT(_iAccumContri)
END_CODE_CONVERT(CClanMember)

class CClanLog : public CTCodeObject
{
public:
    CClanLog () : _uiGid(0), _uiEvent(0), _iTime(0), _uiEventPara1(0),
        _uiEventPara2(0), _uiEventGid(0)
    {
    }

    unsigned int    _uiGid;           //用户GID
    unsigned int    _uiEvent;         //事件ID
    int             _iTime;           //时间发生时间
    unsigned int    _uiEventPara1;    //事件参数1
    unsigned int    _uiEventPara2;    //事件参数2
    unsigned int    _uiEventGid;      //用户GID
};
BEGIN_CODE_CONVERT(CClanLog)
CODE_CONVERT(_uiGid)
CODE_CONVERT(_uiEvent)
CODE_CONVERT(_iTime)
CODE_CONVERT(_uiEventPara1)
CODE_CONVERT(_uiEventPara2)
CODE_CONVERT(_uiEventGid)
END_CODE_CONVERT(CClanLog)

class CTreeEntry : public CTCodeObject
{
public:
    CTreeEntry ()
    {
        Clear ();
    }

    void Clear ()
    {
        _iGrowth = 0;
    }

    void AddGrowth (int iToAddValue)
    {
        if (iToAddValue <= 0)
        {
            return ;
        }

        _iGrowth += iToAddValue;
    }

    int _iGrowth;
};
BEGIN_CODE_CONVERT(CTreeEntry)
CODE_CONVERT(_iGrowth)
END_CODE_CONVERT(CTreeEntry)

class CTreeRankUnit : public CTCodeObject
{
public:
    CTreeRankUnit ()
    {
        _uiGid = 0;
        _iGrowth = 0;
    }

    unsigned int _uiGid;
    int _iGrowth;
};
BEGIN_CODE_CONVERT(CTreeRankUnit)
CODE_CONVERT(_uiGid)
CODE_CONVERT(_iGrowth)
END_CODE_CONVERT(CTreeRankUnit)

class CTreeData : public CTCodeObject
{
public:
    CTreeData ()
    {
        Clear ();
    }

    void Clear ()
    {
        _stTree.m_iUsedCount = MAX_CLAN_TREE_TYPE;
        for (int i = 0; i < _stTree.Size(); i++)
        {
            _stTree[i].Clear();
        }

        _stRank.Clear();
    }

    static bool IsValidTree (unsigned char ucTreeId)
    {
        if (ucTreeId > MAX_CLAN_TREE_TYPE || 0 == ucTreeId)
        {
            return false;
        }

        return true;
    }

    CTreeEntry & GetClanTree (unsigned char ucTreeId)
    {
        return _stTree [ucTreeId - 1];
    }

    int GetRankIndex (unsigned int uiGid)
    {
        for (int i = 0; i < _stRank.Size(); i++)
        {
            if (_stRank[i]._uiGid == uiGid)
            {
                return i;
            }
        }

        return -1;
    }

    void DelInRank (int iIndex)
    {
        _stRank.DelOneItem(iIndex);
    }

    void ShiftDelInRank (unsigned int uiGid)
    {
        int iIndex = GetRankIndex (uiGid);
        if (iIndex >= 0)
        {
            _stRank.ShiftDelOneItem(iIndex);
        }        
    }

    CTArray<CTreeEntry, MAX_CLAN_TREE_TYPE> _stTree;
    CTArray<CTreeRankUnit, MAX_TREE_RANK_SIZE> _stRank;   //下标为i的元素保存第(i+1)名的成员
};
BEGIN_CODE_CONVERT(CTreeData)
CODE_CONVERT(_stTree)
CODE_CONVERT(_stRank)
END_CODE_CONVERT(CTreeData)

class CDiceRankUnit : public CTCodeObject
{
public:
    CDiceRankUnit ()
    {
        _uiGid = 0;
        _iBeseWeekPos = 0;
    }

    unsigned int _uiGid;
    int _iBeseWeekPos;
};
BEGIN_CODE_CONVERT(CDiceRankUnit)
CODE_CONVERT(_uiGid)
CODE_CONVERT(_iBeseWeekPos)
END_CODE_CONVERT(CDiceRankUnit)

class CDiceRank : public CTCodeObject
{
public:
    CDiceRank ()
    {
        Clear();
    }

    void Clear ()
    {
        _stRank.Clear();
    }

    int GetRankIndex (unsigned int uiGid)
    {
        for (int i = 0; i < _stRank.Size(); i++)
        {
            if (_stRank[i]._uiGid == uiGid)
            {
                return i;
            }
        }

        return -1;
    }

    void DelInRank (int iIndex)
    {
        _stRank.DelOneItem(iIndex);
    }

    void ShiftDelInRank (unsigned int uiGid)
    {
        int iIndex = GetRankIndex (uiGid);
        if (iIndex >= 0)
        {
            _stRank.ShiftDelOneItem(iIndex);
        }        
    }
    CTArray<CDiceRankUnit, MAX_DICE_RANK_SIZE> _stRank;   //下标为i的元素保存第(i+1)名的成员
};
BEGIN_CODE_CONVERT(CDiceRank)
CODE_CONVERT(_stRank)
END_CODE_CONVERT(CDiceRank)

class CClanData : public CTCodeObject
{
public:
    CClanData ()
    {
        Clear();
    }

    void Clear ()
    {
        _uiClanID = 0;
        _ucAcademyType = 0;
        _ucClanLevel = 0;
        _iConstruction = 0;
        _iDismissTime = 0;
        _astClanMember.Clear();
        _astJoinReq.Clear();
        _szNotice.Set("");
        _uiChangerGid = 0;
        _szName.Set("");
        _iLastRefreshTime = 0;
        _astItems.Clear();
        _usClanFightingRank = 0;
        _iLastRecommdTime = 0;
        _iAuctionBuffTime = 0;
        _stMagicDoor.Clear();
        _stStorage.Clear();
        _stTree.Clear();
        _stDiceRank.Clear();
        _usDailyRecruitCnt.SetDefault (0);
    }

    unsigned int  _uiClanID;
    unsigned char _ucAcademyType; //学院类型
    unsigned char _ucClanLevel;   //家族等级
    int   _iConstruction;         //家族总建设度
    int   _iDismissTime;          //家族解散时间
    CTArray<CClanMember, MAX_CLAN_MEMBER_COUNT>  _astClanMember;   //家族成员
    CTArray<unsigned int, MAX_CLAN_JOIN_REQ_NUM + 1> _astJoinReq;  //加入家族申请
    CTSizeString<MAX_CLAN_NOTICE_STRING_LEN>  _szNotice;           //家族公告
    unsigned int _uiChangerGid; //修改公告者GID
    CTSizeString<CLAN_NAME_STRING_SIZE> _szName;
    int _iLastRefreshTime;   //上次刷新物品的时间
    CTArray<CShopItemData, MAX_CLAN_SHOP_ITEM>  _astItems;
    unsigned short _usClanFightingRank; //家族战排名
    int _iLastRecommdTime;
    int _iAuctionBuffTime;
    CTArray<CClanLog, MAX_CLAN_LOG_NUM> _astClanLog;          //家族日志
    StorageData _stStorage;  //家族仓库

    CMagicDoorData _stMagicDoor;       //魔界门数据

    CTreeData _stTree;    

    CDiceRank  _stDiceRank;

    CDailyReflushUShort _usDailyRecruitCnt;    //今日已经使用过的招募次数
};
BEGIN_CODE_CONVERT(CClanData)
CODE_CONVERT(_uiClanID)
CODE_CONVERT(_ucAcademyType)
CODE_CONVERT(_ucClanLevel)
CODE_CONVERT(_iConstruction)
CODE_CONVERT(_iDismissTime)
CODE_CONVERT(_astClanMember)
CODE_CONVERT(_astJoinReq)
CODE_CONVERT(_szNotice)
CODE_CONVERT(_uiChangerGid)
CODE_CONVERT(_szName)
CODE_CONVERT(_iLastRefreshTime)
CODE_CONVERT(_astItems)
CODE_CONVERT(_usClanFightingRank)
CODE_CONVERT(_iLastRecommdTime)
CODE_CONVERT(_astClanLog)
CODE_CONVERT(_stStorage)
CODE_CONVERT(_stMagicDoor)
CODE_CONVERT(_iAuctionBuffTime)
CODE_CONVERT(_stTree)
CODE_CONVERT(_stDiceRank)
CODE_CONVERT(_usDailyRecruitCnt)
END_CODE_CONVERT(CClanData)

//上课数据
class CLessonData : public CTCodeObject
{
public:
    CLessonData()
    {
        _ucLessonID = 0;
        _ucLessonLevel = 0;
        _ucNowExp = 0;
        _ucHasTest = 0;
    }

public:
    unsigned char _ucLessonID;      //当前课程id
    unsigned char _ucLessonLevel;   //当前等级
    unsigned char _ucNowExp;        //当前经验
    unsigned char _ucHasTest;       //是否已经考试
};
BEGIN_CODE_CONVERT(CLessonData)
CODE_CONVERT(_ucLessonID)
CODE_CONVERT(_ucLessonLevel)
CODE_CONVERT(_ucNowExp)
CODE_CONVERT(_ucHasTest)
END_CODE_CONVERT(CLessonData)

class CUserLessonData : public CTCodeObject
{
public:
    enum
    {
        LESSON_TYPE_MIN = 1,

        LESSON_TYPE_REQUIRED = 1, //选修课
        LESSON_TYPE_ELECTIVE = 2, //必修课

        LESSON_TYPE_MAX = 2,
    };

    CUserLessonData()
    {
        Clear();
    }

    void Clear()
    {
        _uiGID = 0;

        _bSysOpenElectiveLesson = false;

        _ucCanTakeRequiredLesson = 0;
        _ucCanTakeElectiveLesson = 0;

        _astLessonDatas.Clear();

        _ucCanTakeRequiredLessonCount = 0;
        _iLastTakeRequiredLessonTime = 0;
        _ucHasBuyRequiredLessonCount = 0;
        _iLastBuyRequiredLessonTime = 0;

        _ucCanTakeElectiveLessonCount = 0;
        _iLastTakeElectiveLessonTime = 0;
        _ucHasBuyElectiveLessonCount = 0;
        _iLastBuyElectiveLessonTime = 0;

        _iNextCanTakeLessonTime = 0;
        _ucNowLessonID = 0;

        _ucBuyFlushTakeLessonCount = 0;

        _cNextRequiredLessonID = 0;
        _cNextElectiveLessonID = 0;

        _iLessonPoint = 0;
    }

    int GetCanTakeRequiredLessonCount(int iNowTime)
    {
        if (_ucCanTakeRequiredLessonCount >= MAX_DEFAULT_REQUIRED_LESSON_COUNT)
        {
            return _ucCanTakeRequiredLessonCount;
        }

        if (CTTimeUtils::IsSameDay(iNowTime, _iLastTakeRequiredLessonTime))
        {
            return _ucCanTakeRequiredLessonCount;
        }

        return MAX_DEFAULT_REQUIRED_LESSON_COUNT;
    }

    int GetHasBuyRequiredLessonCount(int iNowTime)
    {
        if (CTTimeUtils::IsSameDay(iNowTime, _iLastBuyRequiredLessonTime))
        {
            return _ucHasBuyRequiredLessonCount;
        }

        return 0;
    }

    int GetCanTakeElectiveLessonCount(int iNowTime)
    {
        if (_ucCanTakeElectiveLessonCount >= MAX_DEFAULT_ELECTIVE_LESSON_COUNT)
        {
            return _ucCanTakeElectiveLessonCount;
        }

        if (CTTimeUtils::IsSameDay(iNowTime, _iLastTakeElectiveLessonTime))
        {
            return _ucCanTakeElectiveLessonCount;
        }

        return MAX_DEFAULT_ELECTIVE_LESSON_COUNT;
    }

    int GetHasBuyElectiveLessonCount(int iNowTime)
    {
        if (CTTimeUtils::IsSameDay(iNowTime, _iLastBuyElectiveLessonTime))
        {
            return _ucHasBuyElectiveLessonCount;
        }

        return 0;
    }

    int GetCanTakeLessonCount(unsigned char ucLessonType, int iNowTime)
    {
        switch (ucLessonType)
        {
        case LESSON_TYPE_REQUIRED:
            return GetCanTakeRequiredLessonCount(iNowTime);
        case LESSON_TYPE_ELECTIVE:
            return GetCanTakeElectiveLessonCount(iNowTime);
        default:
            return 0;
        }
    }

    int GetNextLessonID(unsigned char ucLessonType)
    {
        switch (ucLessonType)
        {
        case LESSON_TYPE_REQUIRED:
            return _cNextRequiredLessonID;
        case LESSON_TYPE_ELECTIVE:
            return _cNextElectiveLessonID;
        default:
            return 0;
        }
    }

public:
    unsigned int _uiGID;                        //(不入库)
    bool    _bSysOpenElectiveLesson;            //是否已经达到使用选修课的条件, 不入库
    int     _iMaxCanBuyLessonTimes;             //最大可购买上课次数，不入库

    unsigned char _ucCanTakeRequiredLesson;     //必修课是否开放
    unsigned char _ucCanTakeElectiveLesson;     //选修课是否开放

    CTLib::CTArray<CLessonData, MAX_LESSON_COUNT + 1> _astLessonDatas; //课程信息

    unsigned char _ucCanTakeRequiredLessonCount;        //已经上必修课的次数
    int _iLastTakeRequiredLessonTime;                   //最后一次上必修课的时间
    unsigned char _ucHasBuyRequiredLessonCount;         //已经购买必修课的次数
    int _iLastBuyRequiredLessonTime;                    //最后一次购买必修课的时间

    unsigned char _ucCanTakeElectiveLessonCount;        //已经上选修课的次数
    int _iLastTakeElectiveLessonTime;                   //最后一次上选修课的时间
    unsigned char _ucHasBuyElectiveLessonCount;         //已经购买选修课的次数
    int _iLastBuyElectiveLessonTime;                    //最后一次购买选修课的时间

    int _iNextCanTakeLessonTime;            //下次可上课时间
    unsigned char _ucNowLessonID;            //当前上课ID

    unsigned char _ucBuyFlushTakeLessonCount; //购买上课时间刷新次数;

    char _cNextRequiredLessonID;                        //当前必修课程
    char _cNextElectiveLessonID;                        //当前选修课程

    int _iLessonPoint;                                  //学分
};

BEGIN_CODE_CONVERT(CUserLessonData)
CODE_CONVERT(_ucCanTakeRequiredLesson)
CODE_CONVERT(_ucCanTakeElectiveLesson)

CODE_CONVERT(_astLessonDatas)

CODE_CONVERT(_ucCanTakeRequiredLessonCount)
CODE_CONVERT(_iLastTakeRequiredLessonTime)
CODE_CONVERT(_ucHasBuyRequiredLessonCount)
CODE_CONVERT(_iLastBuyRequiredLessonTime)

CODE_CONVERT(_ucCanTakeElectiveLessonCount)
CODE_CONVERT(_iLastTakeElectiveLessonTime)
CODE_CONVERT(_ucHasBuyElectiveLessonCount)
CODE_CONVERT(_iLastBuyElectiveLessonTime)

CODE_CONVERT(_iNextCanTakeLessonTime)
CODE_CONVERT(_ucNowLessonID)

CODE_CONVERT(_ucBuyFlushTakeLessonCount)

CODE_CONVERT(_cNextRequiredLessonID)
CODE_CONVERT(_cNextElectiveLessonID)

CODE_CONVERT(_iLessonPoint)
END_CODE_CONVERT(CUserLessonData)

#define  MIN_BIG_FRUIT    (1)   //大果实最小的ID。 大果实有效值范围:[1,7]
#define  MIN_SMALL_FRUIT  (MAX_BIG_FRUIT_CNT + 2)   //小果实最小的ID. 小果实有效范围[9,15]
class CTreeOptCnt : public CTCodeObject
{
public:
    CTreeOptCnt ()
    {
        Clear();
    }

    void Clear ()
    {
        _stWaterCnt.Clear ();
        _usFruits = 0;

        _stWaterCnt.SetDefault(0);
    }

    int SetFruit (int iBigFruitCnt, int iSmallFruitCnt)
    {
        if (iBigFruitCnt > MAX_BIG_FRUIT_CNT || iSmallFruitCnt > MAX_SAMALL_FRUIT_CNT)
        {
            return ERROR_PICK_FRUIT_CNT;
        }

        //大果实位置[1,7],  小果树[9,15]
        for (int i = 0; i < iBigFruitCnt; ++i)
        {
            CT_BIT_SET(_usFruits, (MIN_BIG_FRUIT + i));
        }

        for (int i = 0; i < iSmallFruitCnt; ++i)
        {
            CT_BIT_SET(_usFruits, (MIN_SMALL_FRUIT + i));
        }

        return 0;
    }

    bool HasFruit (int iFruit)
    {
        return CT_BIT_TEST(_usFruits, iFruit);
    }

    void ClearFruit (int iFruit)
    {
        CT_BIT_CLR(_usFruits, iFruit);
    }

    CDailyReflushChar  _stWaterCnt;    //今日浇水次数
    unsigned short _usFruits;          //未摘果实
};
BEGIN_CODE_CONVERT(CTreeOptCnt)
CODE_CONVERT(_stWaterCnt)
CODE_CONVERT(_usFruits)
END_CODE_CONVERT(CTreeOptCnt)

//用户的魔界传送门数据
class CUserMagicDoor : public CTCodeObject
{
public:
    CUserMagicDoor()
    {
        Clear();
    }

    void Clear()
    {
        _iTimes = 0;
        _iLastPayTime = 0;
        _stPayContriTimes.Clear();
    }

public:
    int _iTimes;
    int _iLastPayTime;//上次充能时间
    CDailyReflushShort _stPayContriTimes;//魔界门充能次数 分为两个char存储次数
};
BEGIN_CODE_CONVERT(CUserMagicDoor)
CODE_CONVERT(_iTimes)
CODE_CONVERT(_iLastPayTime)
CODE_CONVERT(_stPayContriTimes)
END_CODE_CONVERT(CUserMagicDoor)

//用户的家族神树信息
class CUserTree : public CTCodeObject
{
public:
    CUserTree ()
    {
        Clear();
    }

    void Clear ()
    {
        _astOptCnt.m_iUsedCount = MAX_CLAN_TREE_TYPE;
        for (int i = 0; i < _astOptCnt.Size(); i++)
        {
            _astOptCnt[i].Clear();
        }
    }

    bool HasPickCnt ()
    {
        for (int i = 0; i < _astOptCnt.Size(); i++)
        {
            if (_astOptCnt[i]._usFruits > 0)
            {
                return true;
            }
        }

        return false;
    }

    int GetBuyWaterCnt (int iNowTime)  //获取已购买的神树浇水次数
    {
        int iBuyCnt = 0;
        for (int i = 0; i < _astOptCnt.Size(); i++)
        {
            CDailyReflushChar & stWaterCnt = _astOptCnt[i]._stWaterCnt;
            iBuyCnt += CT_MAX(stWaterCnt.Get(iNowTime, MAX_CLEAR_TREE_TIME) - MAX_FREE_WATER_TIMES,  0);
        }

        return iBuyCnt;
    }

    CTreeOptCnt & GetTreeOptCnt (unsigned char ucTreeId)
    {
        return _astOptCnt[ucTreeId -1];
    }

    void ClearFruitCount ()  //清空摘果次数
    {
        for (int i = 0; i < _astOptCnt.Size(); i++)
        {
            _astOptCnt[i]._usFruits = 0;
        }
    }

    CTArray<CTreeOptCnt, MAX_CLAN_TREE_TYPE> _astOptCnt;
};
BEGIN_CODE_CONVERT(CUserTree)
CODE_CONVERT(_astOptCnt)
END_CODE_CONVERT(CUserTree)

//////////////////////////////////////////////////////////////////////////
class CUserClan : public CTCodeObject
{
public:
    typedef CTLib::CTArray<CAttrPair, MAX_CLAN_SKILL_NUM> T_CLAN_SKILL;
    CUserClan ()
    {
        Clear();
    }

    void Clear ()
    {
        _uiClanId = 0;
        _astJoinReq.Clear();
        _astClanSkill.Clear();
        _astPendingBonus.Clear();
        _iJoinTime = 0;
        _stMagicDoor.Clear();
        _stTreeData.Clear();
        _stDailCnt.SetDefault(0);
        _uiJoinedCount = 0;
    }

    void ClearWhenNoClan ()
    {        
        _uiClanId = 0;
        _iJoinTime = 0;

        _astJoinReq.Clear();

        //清空摘果次数
        _stTreeData.ClearFruitCount ();

        _stMagicDoor.Clear();
    }

    int AddJoinReq (unsigned int uiClanId)
    {
        if (_astJoinReq.Size() >= MAX_JOIN_CLAN_REQ_PER_USER)
        {
            return ERROR_CLAN_JOIN_REQ_FULL;
        }

        for (int i = 0; i < _astJoinReq.Size(); i++)
        {
            if (_astJoinReq[i] == uiClanId)
            {
                return ERROR_CLAN_REPEATED_REQ;
            }
        }

        _astJoinReq.AddOneItem(uiClanId);
        return 0;
    }

    int DelJoinReq (unsigned int uiClanId)
    {
        for (int i = 0; i < _astJoinReq.Size(); i++)
        {
            if (_astJoinReq[i] == uiClanId)
            {
                _astJoinReq.DelOneItem(i);
                break;
            }
        }        

        return 0;
    }

    int ClearJoinReq ()
    {
        _astJoinReq.Clear();
        return 0;
    }

    int AddBonus (StorageItemData & stItem)
    {
        if (_astPendingBonus.Size() >= MAX_CLAN_PENDING_BONUS)
        {
            return ERROR_CLAN_PENDING_FULL;
        }

        if (ITEM_TYPE_GIFT != stItem._ucItemType)
        {
            CT_ERROR(("%d, %d, %d, %d", _uiClanId, stItem._ucItemType, stItem._uiItemID, stItem._shItemCount));
            return ERROR_WRONG_ITEM_TYPE;
        }

        for (int i = 0 ; i < _astPendingBonus.Size(); i++)
        {
            if (_astPendingBonus[i]._ucItemType == stItem._ucItemType
                && _astPendingBonus[i]._uiItemID == stItem._uiItemID
                && _astPendingBonus[i]._shItemCount + stItem._shItemCount < 32767)
            {
                _astPendingBonus[i]._shItemCount += stItem._shItemCount;
                return 0;
            }
        }

        stItem._usStorePos = _astPendingBonus.m_iUsedCount;
        _astPendingBonus.AddOneItem(stItem);
        return 0;
    }

    int GetFreeGridCnt ()
    {
        return (MAX_CLAN_PENDING_BONUS - _astPendingBonus.Size());
    }

    //之前加入过家族返回真, 未加入过返回假
    bool HasJoinedClanBefore ()
    {
        return (_uiJoinedCount > 1);
    }

    //更新存量用户首次加入家族标志
    void UpdateJoinClanCount ()
    {
        if (0 == _uiJoinedCount  || _uiClanId > 0 || _iJoinTime > 0)
        {
            _uiJoinedCount = 1;
        }        
    }

public:
    unsigned int _uiClanId;
    CTArray<unsigned int, MAX_JOIN_CLAN_REQ_PER_USER>  _astJoinReq;
    CTArray<CAttrPair, MAX_CLAN_SKILL_NUM>         _astClanSkill;
    CTArray<StorageItemData, MAX_CLAN_PENDING_BONUS>  _astPendingBonus;

    int _iJoinTime;         //加入家族时间
    CUserTree               _stTreeData; //家族神树信息
    CUserMagicDoor          _stMagicDoor;//魔界传送门个人数据
    CDailyReflushUChar      _stDailCnt;  //家族转盘已用次数
    unsigned int            _uiJoinedCount; //加入不同家族的计数
};

BEGIN_CODE_CONVERT(CUserClan)
CODE_CONVERT(_uiClanId)
CODE_CONVERT(_astJoinReq)
CODE_CONVERT(_astClanSkill)
CODE_CONVERT(_astPendingBonus)
CODE_CONVERT(_iJoinTime)
CODE_CONVERT(_stTreeData)
CODE_CONVERT(_stMagicDoor)
CODE_CONVERT(_stDailCnt)
CODE_CONVERT(_uiJoinedCount)
END_CODE_CONVERT(CUserClan)


//家族闯关
class CFamilyDiceData:public CTCodeObject
{
public:
    CFamilyDiceData()
    {
        Clear();
    }

public:
    CDailyReflushShort _sGridId;             //当前格子位置
    CDailyReflushShort _sDiceRestCounts;     //剩余可以投骰子的次数
    CDailyReflushShort _sBuyCounts;          //今日金币购买的次数

    CDailyReflushShort _sDailyRepution;     //今日获得的声望
    CDailyReflushShort _sDailySilver;       //今日获得的银币
    CDailyReflushShort _sDailyExper;        //今日获得的经验

    CDailyReflushInt   _iDailyRepution;     //今日获得的声望
    CDailyReflushInt   _iDailySilver;       //今日获得的银币
    CDailyReflushInt   _iDailyExp;         //今日获得的经验
    CDailyReflushInt   _iDailyContri;       //今日获得的贡献度

    int _iWeekBestGrid;
    int _iNextBestTime;
public:
    void Clear()
    {
        _sGridId.SetDefault(0);
        _sDiceRestCounts.SetDefault( CONST_DAILY_DICE_COUNTS );
        _sBuyCounts.SetDefault( 0 );

        _sDailyRepution.SetDefault( 0 );
        _sDailySilver.SetDefault( 0 );
        _sDailyExper.SetDefault( 0 );

        _iDailyRepution.SetDefault( 0 );
        _iDailySilver.SetDefault( 0 );
        _iDailyExp.SetDefault( 0 );
        _iDailyContri.SetDefault( 0 );

        _iWeekBestGrid = 0;
        _iNextBestTime = 0;
    }
};
BEGIN_CODE_CONVERT(CFamilyDiceData)
CODE_CONVERT(_sGridId)
CODE_CONVERT(_sDiceRestCounts)
CODE_CONVERT(_sBuyCounts)
CODE_CONVERT(_sDailyRepution)
CODE_CONVERT(_sDailySilver)
CODE_CONVERT(_sDailyExper)
CODE_CONVERT(_iDailyRepution)
CODE_CONVERT(_iDailySilver)
CODE_CONVERT(_iDailyExp)
CODE_CONVERT(_iDailyContri)
CODE_CONVERT(_iWeekBestGrid)
CODE_CONVERT(_iNextBestTime)
END_CODE_CONVERT(CFamilyDiceData);

//////////////////////////////////////////////////////////////////////////
enum EN_MINE_TYPE
{
    MINE_TYPE_NONE = 0, 	//无效的购买类型
    MINE_TYPE_LOW  = 1, 	//浅层开采
    MINE_TYPE_DEEP = 2,		//深层开采
    MINE_TYPE_CORE = 3, 	//核心开采
    MINE_TYPE_MAX  = 3,     //最大的开采类型
};

//魔晶开采数据
class CMineCrystalData : public CTCodeObject
{
public:
    CMineCrystalData ()
    {
        _iClearTime = 0;
        _iLowMineCount = 0;
        _iDeepMineCount = 0;
    }

    //获取第icnt后次开采的信息. iCost返回折后价, iLeftCnt返回按当前折扣开采的剩余次数,
    void GetLowMineCost (int & iDiscount, int & iCost, int & iLeftCnt, int iCnt = 0)
    {
        int iMineCount = _iLowMineCount + iCnt ;
        int iTotalCost = 100000;
        if (iMineCount < 5)
        {
            iDiscount = 2;
            iLeftCnt = 5 - _iLowMineCount;
        }else if (iMineCount < 10)
        {
            iDiscount = 4;
            iLeftCnt = 10 - _iLowMineCount;
        }else if (iMineCount < 15)
        {
            iDiscount = 6;
            iLeftCnt = 15 - _iLowMineCount;
        }else if (iMineCount < 20)
        {
            iDiscount = 8;
            iLeftCnt = 20 - _iLowMineCount;
        }else
        {
            iDiscount = 10;
            iLeftCnt = 65535;
        }

        iCost = (iTotalCost * iDiscount) / 10;
        return ;
    }

    int _iClearTime;     //下次刷新开采次数的时间
    int _iLowMineCount;  //浅层开采次数
    int _iDeepMineCount; //深层层开采次数
};
BEGIN_CODE_CONVERT(CMineCrystalData)
CODE_CONVERT(_iClearTime)
CODE_CONVERT(_iLowMineCount)
CODE_CONVERT(_iDeepMineCount)
END_CODE_CONVERT(CMineCrystalData)

//////////////////////////////////////////////////////////////////////////
//炼金数据
class CUserAlchemy : public CTCodeObject
{
public:
    CUserAlchemy()
    {
        _iLastOptTime = 0;
        _iUseFreeOptTimes = 0;
        _iTotalBuyOptTimes = 0;
    }

    //获取一次可以炼金的次数
    static int GetConfigOptTimesPerTime(unsigned char ucVipLevel)
    {
        if (ucVipLevel < 3)
        {
            return 1;
        }
        else
        {
            return 10;
        }
    }

    //每天可使用金币炼金的次数
    int GetConfigUseGoldCanOptTimes(unsigned char ucVipLevel) const
    {
        return _iBuyOptConfigTimes;
    }

    //每天可免费炼金的次数
    int GetConfigFreeOptTimes(unsigned char ucVipLevel) const
    {
        return _iFreeOptConfigTimes;
    }

    //花费
    static int GetConfigOptPrice(int iHasOptTimes)
    {
        if (iHasOptTimes < 0)
        {
            CT_ERROR((""));
            return 0;
        }

        iHasOptTimes++;

        if (iHasOptTimes <= 10)
        {
            return iHasOptTimes * 2;
        }
        else if (iHasOptTimes <= 30)
        {
            return 20;
        }
        else if (iHasOptTimes <= 50)
        {
            return 40;
        }
        else if (iHasOptTimes <= 100)
        {
            return 60;
        }

        return 100;
    }

    int GetFreeOptTimes(unsigned char ucVipLevel, int iNowTime)
    {
        return CT_MAX(0, GetConfigFreeOptTimes(ucVipLevel) - HasUseFreeOptTimes(ucVipLevel, iNowTime));
    }

    //当前已使用免费炼金次数
    int HasUseFreeOptTimes(unsigned char ucVipLevel, int iNowTime) const
    {
        if (_iUseFreeOptTimes < 0)
        {
            return _iUseFreeOptTimes;
        }

        if (CTTimeUtils::IsSameDay(iNowTime, _iLastOptTime, DATA_RESET_SEC_OF_DAY))
        {
            return _iUseFreeOptTimes;
        }
        else
        {
            return 0;
        }
    }

    //已经购买的炼金次数
    int GetTotalBuyOptTimes(int iNowTime)
    {
        if (CTTimeUtils::IsSameDay(iNowTime, _iLastOptTime, DATA_RESET_SEC_OF_DAY))
        {
            return _iTotalBuyOptTimes;
        }
        else
        {
            return 0;
        }
    }

    //获取总共可炼金的次数
    int GetCanOptCount(unsigned char ucVipLevel, int iNowTime)
    {
        return  GetFreeOptTimes(ucVipLevel, iNowTime) + GetConfigUseGoldCanOptTimes(ucVipLevel) - GetTotalBuyOptTimes(iNowTime);
    }

    //获取炼金价格
    int GetPrice(unsigned char ucVipLevel, int iCount, int iNowTime, int& iPrice)
    {
        iPrice = 0;
        if (iCount <= 0)
        {
            return 0;
        }

        if (iCount > GetCanOptCount(ucVipLevel, iNowTime))
        {
            return RET_SYS_ERROR;
        }

        int iBuyCount = iCount - GetFreeOptTimes(ucVipLevel, iNowTime); //计算需要购买的次数
        if (iBuyCount <= 0)
        {
            return 0;
        }

        int iTotalBuyOptTimes = GetTotalBuyOptTimes(iNowTime); //当前已经购买的次数
        for (int i = 0; i < iBuyCount; ++i)
        {
            iPrice += GetConfigOptPrice(iTotalBuyOptTimes + i);
        }

        return 0;
    }

    //添加免费次数（使用卷轴）
    void AddFreeOptTimes(unsigned char ucVipLevel, int iCount, int iNowTime)
    {
        _iUseFreeOptTimes = GetFreeOptTimes(ucVipLevel, iNowTime);
        _iUseFreeOptTimes -= iCount;
        _iTotalBuyOptTimes = GetTotalBuyOptTimes(iNowTime);

        _iLastOptTime = iNowTime;
    }

    //添加炼金次数(炼金后调用)
    int AddOptTimes(unsigned char ucVipLevel, int iCount, int iNowTime)
    {
        if (iCount > GetCanOptCount(ucVipLevel, iNowTime))
        {
            return RET_SYS_ERROR;
        }

        int iNowFreeOptTimes = GetFreeOptTimes(ucVipLevel, iNowTime);

        if (iCount <= iNowFreeOptTimes)
        {
            _iUseFreeOptTimes = HasUseFreeOptTimes(ucVipLevel, iNowTime) + iCount;
            _iTotalBuyOptTimes = GetTotalBuyOptTimes(iNowTime);
            _iLastOptTime = iNowTime;
            return 0;
        }

        int iLeftTimes = iCount - iNowFreeOptTimes;
        _iUseFreeOptTimes = HasUseFreeOptTimes(ucVipLevel, iNowTime) + iNowFreeOptTimes;
        _iTotalBuyOptTimes = GetTotalBuyOptTimes(iNowTime) + iLeftTimes;
        _iLastOptTime = iNowTime;

        return 0;
    }

public:
    int _iLastOptTime;          //最后一次操作时间

    int _iUseFreeOptTimes;        //已使用免费炼金次数
    int _iTotalBuyOptTimes;      //累计已付费炼金次数

    int _iFreeOptConfigTimes;       //免费炼金配置数
    int _iBuyOptConfigTimes;        //付费炼金配置数
};

BEGIN_CODE_CONVERT(CUserAlchemy)
CODE_CONVERT(_iLastOptTime)
CODE_CONVERT(_iUseFreeOptTimes)
CODE_CONVERT(_iTotalBuyOptTimes)
END_CODE_CONVERT(CUserAlchemy)

//////////////////////////////////////////////////////////////////////////
//状态个体
class CStatusObj
{
public:
    CStatusObj()
    {
        Clear();
    }

    void Clear()
    {
        _iResID = 0;
        _iAddNum = 0;
        _iTriTime = 0;
        _iAuxData = 0;
        _iSrcType = 0;
        _uiSrcResID = 0;
    }

public:
    int             _iResID;        //状态配置ID:0 未获得 >0 状态配置ID
    int             _iAddNum;       //叠加层数
    int             _iTriTime;      //生效次数
    int             _iAuxData;      //辅助数据:光荣之手-记录叠加到第几层
                                    //         时间沙漏-至多输出一次日志
                                    //         所罗门的钥匙-三选一随机到的值
                                    //         厄运水晶球-三选一随机到的值
                                    //         隆基努斯长矛-怒气倍率
                                    //         诺顿剑-攻击伤害倍率
    int             _iSrcType;      //来源类型
    unsigned int    _uiSrcResID;    //来源物品配置ID
};

class CStatusList
{
public:
    CStatusList()
    {
        Clear();
    }
    void Clear()
    {
        _astStatus.Clear();
    }

public:
    CTLib::CTArray<CStatusObj, MAX_STATUS_PLAYER_COUNT> _astStatus;
};

//////////////////////////////////////////////////////////////////////////
//秘宝个体
class CTreasureObj
{
public:
    CTreasureObj()
    {
        _shResID = 0;
        _shStatusID = 0;
    }

public:
    short           _shResID;       //秘宝配置ID:0 未获得 >0 秘宝配置ID
    short           _shStatusID;    //状态配置ID:0 未获得 >0 状态配置ID
};

//////////////////////////////////////////////////////////////////////////
//秘宝单元
class CTreasureUnit : public CTCodeObject
{
public:
    CTreasureUnit()
    {
    }

    int Init()
    {
        _chHostType = 0;
        _chHostPos = 0;
        _shResID = 0;
        _shLevel = 0;
        _uiHostID = 0;
        return 0;
    }

public:
    char            _chHostType;    //宿主类型:0 未装配 1 主角 2 伙伴
    char            _chHostPos;     //宿主装配位:0 未装配 1 第一配位 2 第二配位
    short           _shResID;       //秘宝配置ID:0 未获得 >0 秘宝配置ID
    short           _shLevel;       //秘宝等级
    unsigned int    _uiHostID;      //宿主ID:0 未装配 >0 主角GID或伙伴配置ID
};

BEGIN_CODE_CONVERT(CTreasureUnit)
CODE_CONVERT(_chHostType)
CODE_CONVERT(_chHostPos)
CODE_CONVERT(_shResID)
CODE_CONVERT(_shLevel)
CODE_CONVERT(_uiHostID)
END_CODE_CONVERT(CTreasureUnit)

//////////////////////////////////////////////////////////////////////////
//秘宝数据
class CTreasureData : public CTCodeObject
{
public:
    typedef CTLib::CTArray<CTreasureObj, MAX_TREASURE_OBJ_COUNT> T_TREASURE_LIST;

    CTreasureData()
    {
        Clear();
    }

    void Clear()
    {
        _iSpirit = 0;
        _stTreasureList.Clear();
    }

public:
    int     _iSpirit;   //秘宝灵力值
    CTLib::CTArray<CTreasureUnit, MAX_TREASURE_ACT_COUNT> _stTreasureList;
};

BEGIN_CODE_CONVERT(CTreasureData)
CODE_CONVERT(_iSpirit)
CODE_CONVERT(_stTreasureList)
END_CODE_CONVERT(CTreasureData)


//////////////////////////////////////////////////////////////////////////
#define MAX_PENDING_BONUS_COUNT 30    //个人最多未领取的家族奖励数
class CGiftData : public CTCodeObject
{
public:
    CGiftData()
    {
        _iOnlineGiftCnt = 0;
        _iGiftTime = 0;
        _astPendingBonus.Clear();
    }

    int AddBonus (StorageItemData & stItem)
    {
        StorageItemData stToAdd = stItem;
        stToAdd._shItemCount = 1;
        for (int i = 0; i < stItem._shItemCount; i++)
        {
            if (_astPendingBonus.Size() >= MAX_PENDING_BONUS_COUNT)
            {
                _astPendingBonus.ShiftDelOneItem(0);
            }

            _astPendingBonus.AddOneItem(stToAdd);
        }

        return 0;
    }

    bool HasBonus (StorageItemData & stItem)
    {
        for (int i = 0 ; i < _astPendingBonus.Size(); i++)
        {
            if (_astPendingBonus[i]._ucItemType == stItem._ucItemType
                && _astPendingBonus[i]._uiItemID == stItem._uiItemID)
            {
                return true;
            }
        }

        return false;
    }


    int DelBonus (StorageItemData & stItem)
    {
        for (int i = 0 ; i < _astPendingBonus.Size(); i++)
        {
            if (_astPendingBonus[i]._ucItemType == stItem._ucItemType
                && _astPendingBonus[i]._uiItemID == stItem._uiItemID)
            {
                _astPendingBonus.DelOneItem(i);
                return 0;
            }
        }

        return ERROR_GIFT_NONE;
    }

public:
    int _iOnlineGiftCnt;  //已领取的在线礼包数.
    int _iGiftTime;       //领取上个礼包时的“累计在线的时间”
    CTArray<StorageItemData, MAX_PENDING_BONUS_COUNT>  _astPendingBonus;
};
BEGIN_CODE_CONVERT(CGiftData)
CODE_CONVERT(_iOnlineGiftCnt)
CODE_CONVERT(_iGiftTime)
CODE_CONVERT(_astPendingBonus)
END_CODE_CONVERT(CGiftData)

class CMuseData : public CTCodeObject
{
public:
    CMuseData ()
    {
        _iBeginTime = 0;
        _iBeginLevel = 0;
        _iBeginVipLv = 0;
        _iLastCountTime = 0;
        _iAccumExp = 0;
    }

    void StartMuse (int iNowTime, int iNowLv, int iNowVipLv)
    {
        _iBeginTime = iNowTime;
        _iBeginLevel = iNowLv;
        _iBeginVipLv = iNowVipLv;
        _iLastCountTime = iNowTime;
        _iAccumExp = 0;
    }

    void StopMuse ()
    {
        _iBeginTime = 0;
        _iBeginLevel = 0;
        _iBeginVipLv = 0;
        _iLastCountTime = 0;
    }

    bool IsMusing ()
    {
        return (0 == _iBeginTime) ? false : true;
    }

    int _iBeginTime;
    int _iBeginLevel;
    int _iBeginVipLv;
    int _iLastCountTime;  //上次冥想结算的时间
    int _iAccumExp;
};
BEGIN_CODE_CONVERT(CMuseData)
CODE_CONVERT(_iBeginTime)
CODE_CONVERT(_iBeginLevel)
CODE_CONVERT(_iBeginVipLv)
CODE_CONVERT(_iLastCountTime)
CODE_CONVERT(_iAccumExp)
END_CODE_CONVERT(CMuseData)

class CSingleMount : public CTCodeObject
{
public:
    CSingleMount ()
    {
        Clear();
    }

    void Clear ()
    {
        _uiMountId = 0;        
        _usLevel = 1;
        _usSkillLevel = 0;
        _usMatrixLevel = 0;
    }
        
    unsigned int  _uiMountId;    
    unsigned short _usLevel;
    unsigned short _usSkillLevel;
    unsigned short _usMatrixLevel;

};
BEGIN_CODE_CONVERT(CSingleMount)
CODE_CONVERT(_uiMountId)
CODE_CONVERT(_usLevel)
CODE_CONVERT(_usSkillLevel)
CODE_CONVERT(_usMatrixLevel)
END_CODE_CONVERT(CSingleMount)


class CMountData : public CTCodeObject
{
public:
    CMountData ()
    {
        Clear();
    }

    void Clear ()
    {
        _stMounts.m_iUsedCount = _stMounts.GetCount();
        for (int i = 0; i < _stMounts.Size(); i++)
        {
            _stMounts[i].Clear();
        }
        
        _uiNowMount = 0;
        _usFreePos = DEF_MOUNT_FREE_POS;
        _iPurple = 0;
        _iGreen = 0;
        _iGolden = 0;
        _iBlue = 0;
        _sGoldHuntCnt.SetDefault(0);
    }

    int CheckAddMount (unsigned int uiMountId)
    {
        bool bHasEmpty = false;
        for (int i = 0; i < _usFreePos; i++)
        {
            if (uiMountId == _stMounts[i]._uiMountId)
            {                
                return ERROR_MOUNT_REPEAT;
            }

            if (0 == _stMounts[i]._uiMountId)
            {
                bHasEmpty = true;
            }
        }

        if (false == bHasEmpty)
        {
            return ERROR_MOUNT_BAG_FULL;
        }        

        return RET_OK;
    }

    bool CanUnlockPos ()
    {
        return (_usFreePos < MAX_MOUNT_BAG_SIZE);
    }

    int AddMount (unsigned int uiMountId)
    {
        CSingleMount stUnit;
        stUnit._uiMountId = uiMountId;
        for (int i = 0; i < _usFreePos; i++)
        {
            if (0 == _stMounts[i]._uiMountId)
            {
                _stMounts[i] = stUnit;
                return RET_OK;
            }            
        }

        return ERROR_MOUNT_BAG_FULL;        
    }

    int GetMountIndex (unsigned int uiMountId)
    {
        if (uiMountId == 0)
        {
            return -1;
        }

        for (int i = 0; i < _usFreePos; i++)
        {
            if (uiMountId == _stMounts[i]._uiMountId)
            {                
                return i;
            }            
        }

        return -1;
    }

    CTLib::CTArray<CSingleMount, MAX_MOUNT_BAG_SIZE> _stMounts;
    unsigned int _uiNowMount;    //正在骑乘的坐骑
    unsigned short _usFreePos;   //已经解锁的背包位
    int _iGreen;
    int _iBlue;
    int _iGolden;
    int _iPurple;
    CDailyReflushShort _sGoldHuntCnt;
};
BEGIN_CODE_CONVERT(CMountData)
CODE_CONVERT(_stMounts)
CODE_CONVERT(_uiNowMount)
CODE_CONVERT(_usFreePos)
CODE_CONVERT(_iBlue)
CODE_CONVERT(_iGreen)
CODE_CONVERT(_iGolden)
CODE_CONVERT(_iPurple)
CODE_CONVERT(_sGoldHuntCnt)
END_CODE_CONVERT(CMountData)

//怪物攻城战用户数据
class CEnemyAtkCityRoleData : public CTCodeObject
{
public:
    CEnemyAtkCityRoleData()
    {
        Clear();
    }

    void Clear()
    {
        _uiGID = 0;
        _i64TotalAtkData = 0;
        _iLastActTime = 0;
        _iNextCanFightTime = 0;

        _iLastBuyReviveTime = 0;
        _iBuyReviveTimes = 0;

        _bLastBattleIsWin = false;
    }

    void CheckAtk(int iActBeginTime)
    {
        if (_iLastActTime < iActBeginTime)
        {
            _i64TotalAtkData = 0;
        }
    }

    void AddTotalAtkData(int iActBeginTime, int iAtkData)
    {
        CheckAtk(iActBeginTime);
        _i64TotalAtkData += iAtkData;
        _iLastActTime = iActBeginTime;
    }

    int64 GetAtkData(int iActBeginTime)
    {
        CheckAtk(iActBeginTime);
        return _i64TotalAtkData;
    }

    int HasBuyReviveTimes(int iNowTime)
    {
        if (CTTimeUtils::IsSameDay(iNowTime, _iLastBuyReviveTime, DATA_RESET_SEC_OF_DAY))
        {
            return _iBuyReviveTimes;
        }

        return 0;
    }

    int GetRevivePrice(int iNowTime)
    {
        return 5;
        //return CT_MIN(100, (HasBuyReviveTimes(iNowTime) + 1) * 10); // 第一次10金币，之后每次递增10金币，100金币封顶
    }

    void BuyRevive(int iNowTime)
    {
        _iBuyReviveTimes = HasBuyReviveTimes(iNowTime) + 1;
        _iLastBuyReviveTime = iNowTime;
    }

public:
    unsigned int _uiGID;
    int64 _i64TotalAtkData;
    int _iLastActTime;      //上次活动时间
    int _iNextCanFightTime;   //下次可攻击时间

    int _iLastBuyReviveTime; //上次购买复活的时间
    int _iBuyReviveTimes;   //已经购买复活的次数

    bool _bLastBattleIsWin; //上次战斗是否胜利
    int _iLastFightTime;   //上次战斗时间
};

BEGIN_CODE_CONVERT(CEnemyAtkCityRoleData)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_iLastActTime)

CODE_CONVERT(_iLastBuyReviveTime)
CODE_CONVERT(_iBuyReviveTimes)
END_CODE_CONVERT(CEnemyAtkCityRoleData)

//精彩活动 当前结构存储在detailInfo 请使用CSplendidActEx1
class CSplendidAct : public CTCodeObject
{
public:
    CSplendidAct()
    {
        Clear();
    }

    void Clear()
    {
        _ui64GetBonusStat1 = 0;
        _ui64GetBonusStat2 = 0;
        _ui64GetBonusStat3 = 0;
        _ui64GetBonusStat4 = 0;

        _ui64FinishStat1 = 0;
        _ui64FinishStat2 = 0;
        _ui64FinishStat3 = 0;
        _ui64FinishStat4 = 0;

        _iClanRankBonusGiftID = 0;

        _iEnemyAtkCityKillEnemyCount = 0;
        _usEnemyAtkCityGetBonusStat = 0;

        _astCombineCount.m_iUsedCount = _astCombineCount.GetCount();
        for (int i = 0; i < _astCombineCount.Size(); ++i)
        {
            _astCombineCount[i] = 0;
        }

        _astBuyGoldCount.Clear();

        _iPayRankUseQCent = 0;
        _ucHasGetPayRankGift = 0;

        _iHasGetGoldCardCount = 0;
        _ucGoldCardRankBonusCount = 0;
        _ucGoldCardClanBonusCount = 0;

        _ucZPHasGetBigBonus = 0;
        _stZPLuckyPoint.Clear();
        _stZPHasFreeOptCount.Clear();
        _stZPHasGetLuckyBonusTo.Clear();

        ClearZQData();
        ClearGQData();
        ClearGanEnData();
    }

    void ClearGanEnData()
    {
        _iGanEnHammerCount = 0;
        _iGanEnHasGetHammerCount = 0;
        _iGanEnPayGoldCount = 0;
        _ucGanEnHasGetMount = 0;
        _ucGanEnHasGetCry = 0;
        _iGanEnLastOpenTime = 0;
    }

    void ClearZQData()
    {
        _iZQLastOpenTime = 0;
        _ucHasGetZQGift = 0;
    }

    void ClearGQData()
    {
        _iGQLastOpenTime = 0;
        _ucHasGetGQLoginGift = 0;
        _ucHasGQHasLogin = 0;
    }

    //设置已经领取奖励
    int SetGetBonus(int iActID)
    {
        if (iActID == SPLENDID_ACT_ID_NULL
            || iActID > 4 * 64)
        {
            CT_ERROR((""));
            return RET_SYS_ERROR;
        }

        if (iActID <= 64)
        {
            _ui64GetBonusStat1 |= ((uint64)1 << (iActID - 1));
        }
        else if (iActID <= 2 * 64)
        {
            _ui64GetBonusStat2 |= ((uint64)1 << (iActID - 64 - 1));
        }
        else if (iActID <= 3 * 64)
        {
            _ui64GetBonusStat3 |= ((uint64)1 << (iActID - 2 * 64 - 1));
        }
        else if (iActID <= 4 * 64)
        {
            _ui64GetBonusStat3 |= ((uint64)1 << (iActID - 3 * 64 - 1));
        }

        return 0;
    }

    //是否已经领取奖励
    bool HasGetBonus(int iActID)
    {
        if (iActID == SPLENDID_ACT_ID_NULL
            || iActID > 4 * 64)
        {
            CT_ERROR((""));
            return true; //为了安全，缺省用true
        }

        if (iActID <= 64)
        {
            return _ui64GetBonusStat1 & ((uint64)1 << (iActID - 1));
        }
        else if (iActID <= 2 * 64)
        {
            return _ui64GetBonusStat2 & ((uint64)1 << (iActID - 64 - 1));
        }
        else if (iActID <= 3 * 64)
        {
            return _ui64GetBonusStat3 & ((uint64)1 << (iActID - 2 * 64 - 1));
        }
        else if (iActID <= 4 * 64)
        {
            return _ui64GetBonusStat3 & ((uint64)1 << (iActID - 3 * 64 - 1));
        }

        return true;
    }

    //设置完成任务
    int SetFinished(int iActID)
    {
        if (iActID == SPLENDID_ACT_ID_NULL
            || iActID > 4 * 64)
        {
            CT_ERROR((""));
            return RET_SYS_ERROR;
        }

        if (iActID <= 64)
        {
            _ui64FinishStat1 |= ((uint64)1 << (iActID - 1));
        }
        else if (iActID <= 2 * 64)
        {
            _ui64FinishStat2 |= ((uint64)1 << (iActID - 64 - 1));
        }
        else if (iActID <= 3 * 64)
        {
            _ui64FinishStat3 |= ((uint64)1 << (iActID - 2 * 64 - 1));
        }
        else if (iActID <= 4 * 64)
        {
            _ui64FinishStat4 |= ((uint64)1 << (iActID - 3 * 64 - 1));
        }

        return 0;
    }

    bool HasFinished(int iActID)
    {
        if (iActID == SPLENDID_ACT_ID_NULL
            || iActID > 4 * 64)
        {
            CT_ERROR((""));
            return true; //为了安全，缺省用true
        }

        if (iActID <= 64)
        {
            return _ui64FinishStat1 & ((uint64)1 << (iActID - 1));
        }
        else if (iActID <= 2 * 64)
        {
            return _ui64FinishStat2 & ((uint64)1 << (iActID - 64 - 1));
        }
        else if (iActID <= 3 * 64)
        {
            return _ui64FinishStat3 & ((uint64)1 << (iActID - 2 * 64 - 1));
        }
        else if (iActID <= 4 * 64)
        {
            return _ui64FinishStat4 & ((uint64)1 << (iActID - 3 * 64 - 1));
        }

        return true;
    }

public:
    uint64 _ui64FinishStat1;  //通用的是否达成目标状态位，1 << 活动ID然后&
    uint64 _ui64FinishStat2;
    uint64 _ui64FinishStat3;
    uint64 _ui64FinishStat4;

    uint64 _ui64GetBonusStat1;  //通用的是否领取奖励状态位，1 << 活动ID然后&
    uint64 _ui64GetBonusStat2;
    uint64 _ui64GetBonusStat3;
    uint64 _ui64GetBonusStat4;

    //魔晶合成赢幸运活动数据
    CTLib::CTArray<short, MAX_SPLENDID_CRYCOMBINE_LEVEL_COUNT> _astCombineCount;      //魔晶已合成次数/奖励次数

    //家族排名活动奖励数据
    int _iClanRankBonusGiftID;                      //家族排名奖励礼包ID

    //怪物攻城累计击杀奖励
    int _iEnemyAtkCityKillEnemyCount;               //怪物攻城累计击杀怪物数量
    unsigned short _usEnemyAtkCityGetBonusStat;     //领取奖励的状态

    //充值送魔晶活动
    CTLib::CTArray<short, MAX_SPLENDID_BUY_GOLD_SEND_CRY> _astBuyGoldCount; //购买各金币档位的数量 

    //中秋活动
    unsigned char _ucHasGetZQGift;          //是否领取中秋活动奖励

    //消费排行
    int             _iPayRankUseQCent;          //活动期间累计消费(Q分)
    unsigned char   _ucHasGetPayRankGift;       //是否已经领取消费排行奖励

    //国庆登录领奖
    unsigned char _ucHasGetGQLoginGift;     //国庆登录领奖状态
    unsigned char _ucHasGQHasLogin;         //国庆期间是否登录

    //金秋猎金
    int        _iHasGetGoldCardCount;       //获得金色卡片的累计数量
    unsigned char   _ucGoldCardRankBonusCount;   //排名奖励数量，最多1
    unsigned char   _ucGoldCardClanBonusCount;   //排名奖励家族成员数量
    
    //感恩节砸蛋
    int _iGanEnHammerCount;                     //锤子数量
    int _iGanEnHasGetHammerCount;               //已经领取的锤子数量
    int _iGanEnPayGoldCount;                    //充值符石数量
    unsigned char _ucGanEnHasGetMount;          //是否已经领取坐骑
    unsigned char _ucGanEnHasGetCry;            //是否领取魔晶礼包
    int _iGanEnLastOpenTime;                    //砸蛋活动上次开启时间

    //转盘
    unsigned char _ucZPHasGetBigBonus;              //是否已经获得大奖
    CDailyReflushInt _stZPLuckyPoint;               //幸运值
    CDailyReflushUChar _stZPHasFreeOptCount;        //免费次数
    CDailyReflushUChar _stZPHasGetLuckyBonusTo;     //已经领了第几个幸运宝箱

    int     _iZQLastOpenTime;   //中秋上次开启时间
    int     _iGQLastOpenTime;   //国庆上次开启时间
};

BEGIN_CODE_CONVERT(CSplendidAct)
CODE_CONVERT(_ui64GetBonusStat1)
CODE_CONVERT(_ui64GetBonusStat2)
CODE_CONVERT(_ui64GetBonusStat3)
CODE_CONVERT(_ui64GetBonusStat4)

CODE_CONVERT(_astCombineCount)

CODE_CONVERT(_iClanRankBonusGiftID)

CODE_CONVERT(_iEnemyAtkCityKillEnemyCount)
CODE_CONVERT(_usEnemyAtkCityGetBonusStat)

CODE_CONVERT(_ui64FinishStat1)
CODE_CONVERT(_ui64FinishStat2)
CODE_CONVERT(_ui64FinishStat3)
CODE_CONVERT(_ui64FinishStat4)

CODE_CONVERT(_astBuyGoldCount)

CODE_CONVERT(_ucHasGetZQGift)

CODE_CONVERT(_iPayRankUseQCent)
CODE_CONVERT(_ucHasGetPayRankGift)

CODE_CONVERT(_ucHasGetGQLoginGift)

CODE_CONVERT(_iHasGetGoldCardCount)
CODE_CONVERT(_ucGoldCardRankBonusCount)
CODE_CONVERT(_ucGoldCardClanBonusCount)

CODE_CONVERT(_ucHasGQHasLogin)

CODE_CONVERT(_iGanEnHammerCount)
CODE_CONVERT(_iGanEnPayGoldCount)
CODE_CONVERT(_iGanEnHasGetHammerCount)
CODE_CONVERT(_ucGanEnHasGetMount)
CODE_CONVERT(_ucGanEnHasGetCry)

CODE_CONVERT(_stZPLuckyPoint)
CODE_CONVERT(_stZPHasFreeOptCount)
CODE_CONVERT(_ucZPHasGetBigBonus)
CODE_CONVERT(_stZPHasGetLuckyBonusTo)
CODE_CONVERT(_iGanEnLastOpenTime)
CODE_CONVERT(_iZQLastOpenTime)
CODE_CONVERT(_iGQLastOpenTime)
END_CODE_CONVERT(CSplendidAct)

/////////////////////////////////////////////////////////////////////////
class CPlayerRedPacketUnit : public CTCodeObject
{
public:
    CPlayerRedPacketUnit()
    {
        Clear();
    }

    void Clear ()
    {
        _iGold = 0;
        _iSilver = 0;
    }

    virtual ~CPlayerRedPacketUnit()
    {
    }

public:
    int _iGold;
    int _iSilver;
};
BEGIN_CODE_CONVERT(CPlayerRedPacketUnit)
CODE_CONVERT(_iGold)
CODE_CONVERT(_iSilver)
END_CODE_CONVERT(CPlayerRedPacketUnit)

/////////////////////////////////////////////////////////////////////////
class CSplendidActEx1 : public CTCodeObject
{
public:
    CSplendidActEx1()
    {
        Clear();
    }

    void Clear ()
    {
        _usSDGreenNum = 0;
        _usSDBlueNum = 0;
        _usSDPurpleNum = 0;
        _usSDRedNum = 0;
        _iSDChargeGold = 0;
        _stHasGetSDLoginGift.Clear();
        _ucSDGetBigBonus = 0;

        _ucRockBigBonus = 0;
        _iRockScore = 0;
        _iRockScoreSum = 0;
        _aucRockExchange.m_iUsedCount = _aucRockExchange.GetCount();
        for (int i = 0; i < _aucRockExchange.Size(); ++i)
        {
            _aucRockExchange[i] = 0;
        }

        ClearRedPacket();
    }

    void ClearRedPacket()
    {
        _iRedPacketGatherTime = 0;
        _astRedPacket.m_iUsedCount = _astRedPacket.GetCount();
        for (int i = 0; i < _astRedPacket.Size(); ++i)
        {
            _astRedPacket[i]._iGold = 0;
            _astRedPacket[i]._iSilver = 0;
        }
    }

    virtual ~CSplendidActEx1()
    {
    }

public:
    unsigned short _usSDGreenNum;
    unsigned short _usSDBlueNum;
    unsigned short _usSDPurpleNum;
    unsigned short _usSDRedNum;
    int _iSDChargeGold;
    CDailyReflushUChar _stHasGetSDLoginGift;     //双蛋登录领奖状态		
    unsigned char _ucSDGetBigBonus; //是否已获得大奖 不存GID到ZoneData主要避免合服影响

    unsigned char _ucRockBigBonus; //是否已经获得大奖
    int _iRockScore;    //当前积分
    int _iRockScoreSum; //累计积分
    CTLib::CTArray<unsigned char, MAX_SPLENDID_ROCK_EXCHANGE_GIFT> _aucRockExchange;

    int _iRedPacketGatherTime;
    CTLib::CTArray<CPlayerRedPacketUnit, MAX_SPLENDID_RED_PACKET_DB_DAY_COUNT> _astRedPacket;
};

BEGIN_CODE_CONVERT(CSplendidActEx1)
CODE_CONVERT(_usSDGreenNum)
CODE_CONVERT(_usSDBlueNum)
CODE_CONVERT(_usSDPurpleNum)
CODE_CONVERT(_usSDRedNum)
CODE_CONVERT(_iSDChargeGold)
CODE_CONVERT(_stHasGetSDLoginGift)
CODE_CONVERT(_ucSDGetBigBonus)
CODE_CONVERT(_ucRockBigBonus)
CODE_CONVERT(_iRockScore)
CODE_CONVERT(_iRockScoreSum)
CODE_CONVERT(_aucRockExchange)
CODE_CONVERT(_iRedPacketGatherTime)
CODE_CONVERT(_astRedPacket)
END_CODE_CONVERT(CSplendidActEx1)

//金字塔活动
class CPyramidActDataDetail : public CTCodeObject
{
public:
    CPyramidActDataDetail()
    {
        _ucCanEnter = 0;
        _ucHasGetWinBonus = 0;
        _ucHasGetAllKillBonus = 0;
        _u64HasAtkPos = 1;
        _stNowIndex.SetDefault(1);
        _stHasResetCount.SetDefault(0);
    }

    //获取层数以及在该层的位置
    int GetLevelAndPos(unsigned char ucIndex, unsigned char& ucLevel, unsigned char& ucPos)
    {
        ucLevel = 1;
        ucPos = 1;

        while (ucIndex > ucLevel * ucPos)
        {
            ucIndex -= ucLevel * ucPos;
            ucLevel++;
        }

        ucPos = ucIndex;
        return 0;
    }

    //获取索引
    unsigned char GetIndex(unsigned char ucLevel, unsigned char ucPos)
    {
        return (1 + (ucLevel - 1)) * (ucLevel - 1) / 2 + ucPos;
    }

    //是否有怪
    bool HasEnemy(unsigned char ucIndex)
    {
        return !(_u64HasAtkPos & ((uint64)1 << (ucIndex - 1)));
    }

    bool HasEnemy(unsigned char ucLevel, unsigned char ucPos)
    {
        return HasEnemy(GetIndex(ucLevel, ucPos));
    }

    void SetKillEnemy(unsigned char ucIndex)
    {
        _u64HasAtkPos |= (uint64)1 << (ucIndex - 1);
    }

    //是否可到达
    bool IsCanGo(unsigned char ucLevel, unsigned char ucPos, int iNowTime)
    {
        if (ucLevel == 0 || ucPos == 0
           || ucLevel > MAX_PYRAMID_LEVEL
           || ucPos > ucLevel)
        {
            CT_ERROR((""));
            return false;
        }

        unsigned char ucNowIndex = _stNowIndex.Get(iNowTime);
        if (_stNowIndex.Get(iNowTime) == 0)
        {
            CT_ERROR((""));
            return false;
        }

        unsigned char ucNowLevel;
        unsigned char ucNowPos;
        GetLevelAndPos(ucNowIndex, ucNowLevel, ucNowPos);

        if (ucLevel != ucNowLevel + 1) //下层
        {
            return false;
        }

        if (ucNowPos != ucPos && ucNowPos != ucPos + 1) //下层连接点
        {
            return false;
        }

        return true;
    }

    int GetAtkEnemyCount()
    {
        int iCount = 0;
        uint64 _u64HasAtkPosTmp = _u64HasAtkPos;

        while (_u64HasAtkPosTmp)
        {
            _u64HasAtkPosTmp &= (_u64HasAtkPosTmp - 1);
            iCount++;
        }

        return iCount - 1; //初始格子不算
    }

public:
    unsigned char _ucCanEnter;              //是否可以进入 
    unsigned char _ucHasGetWinBonus;        //是否已经领取击穿奖励 0: 未获得 1: 可领取 2: 已领取
    unsigned char _ucHasGetAllKillBonus;    //是否已经领取全杀奖励 0: 未获得 1: 可领取 2: 已领取
    uint64 _u64HasAtkPos;                   //已经被攻打过的格子
    CDailyReflushUChar _stNowIndex;         //当前位置
    CDailyReflushUChar _stHasResetCount;    //已经重置的次数
};

BEGIN_CODE_CONVERT(CPyramidActDataDetail)
CODE_CONVERT(_ucCanEnter)
CODE_CONVERT(_ucHasGetWinBonus)
CODE_CONVERT(_ucHasGetAllKillBonus)
CODE_CONVERT(_u64HasAtkPos)
CODE_CONVERT(_stNowIndex)
CODE_CONVERT(_stHasResetCount)
END_CODE_CONVERT(CPyramidActDataDetail)

class CPyramidActData : public CTCodeObject
{
public:
    CPyramidActData()
    {
    }

public:
    CTLib::CTArray<CPyramidActDataDetail, MAX_PYRAMID_COUNT> _astPyramidActDatas;
};

BEGIN_CODE_CONVERT(CPyramidActData)
CODE_CONVERT(_astPyramidActDatas)
END_CODE_CONVERT(CPyramidActData)

//////////////////////////////////////////////////////////////////////////
class CPlayerDetailInfo : public CTCodeObject
{
public:
    CPlayerDetailInfo()
    {
        _iReputation = 0;

        _stPlayerMatrix.Clear();
        _stUserDBSkill.Clear();
        _stPlayerEquip.Clear();

        _stUserArenaData.Clear();
        _stDrugData.Clear();
        _stTreasureData.Clear();
        _stDiceData.Clear();
        _stWishData.Clear();
    }

    int  WearEquip(unsigned int uiEquipID, int iPos)
    {
        if (uiEquipID == 0)
        {
            return ERROR_EQUIP_UNKNOW_ID;
        }

        unsigned int uiEquip;
        int iRet = _stPlayerEquip.GetEquip(uiEquip, iPos);
        CT_RETURN(iRet);

        if (uiEquip != 0)
        {
            return ERROR_EQUIP_ADD_DUPLICATE;
        }

        iRet = _stPlayerEquip.SetEquip(uiEquipID, iPos);
        CT_RETURN(iRet);

        return 0;
    }

    int  TakeOffEquip(unsigned int uiEquipID, int iPos)
    {
        if (uiEquipID == 0)
        {
            return ERROR_EQUIP_UNKNOW_ID;
        }

        unsigned int uiEquip;
        int iRet = _stPlayerEquip.GetEquip(uiEquip, iPos);
        CT_RETURN(iRet);

        if (uiEquip == 0)
        {
            return ERROR_EQUIP_ALREADY_TAKEOFF;
        }
        if (uiEquip != uiEquipID)
        {
            return ERROR_EQUIP_UNKNOW_ID;
        }

        iRet = _stPlayerEquip.SetEquip(0, iPos);
        CT_RETURN(iRet);

        return 0;
    }

    static void TraceSize()
    {
        CT_TRACE(("CPlayerMatrix %d", sizeof(CPlayerMatrix)));
        CT_TRACE(("CPartnerData %d", sizeof(CPartnerData)));
        CT_TRACE(("CEquipData %d", sizeof(CEquipData)));
        CT_TRACE(("StorageData %d", sizeof(StorageData)));
        CT_TRACE(("CPlayerDBSkill %d", sizeof(CPlayerDBSkill)));
        CT_TRACE(("CPlayerEquip %d", sizeof(CPlayerEquip)));
        CT_TRACE(("CUserDivineData %d", sizeof(CUserDivineData)));
        CT_TRACE(("CUserCardData %d", sizeof(CUserCardData)));
        CT_TRACE(("CPlayerWareCard %d", sizeof(CPlayerWareCard)));
        CT_TRACE(("CCardVortex %d", sizeof(CCardVortex)));
        CT_TRACE(("CPlayerSoulData %d", sizeof(CPlayerSoulData)));
        CT_TRACE(("CShopData %d", sizeof(CShopData)));
        CT_TRACE(("CDrugData %d", sizeof(CDrugData)));
        CT_TRACE(("CMineCrystalData %d", sizeof(CMineCrystalData)));
        CT_TRACE(("CUserArenaData %d", sizeof(CUserArenaData)));
        CT_TRACE(("CUserClan %d", sizeof(CUserClan)));
        CT_TRACE(("CUserLessonData %d", sizeof(CUserLessonData)));
        CT_TRACE(("CUserAlchemy %d", sizeof(CUserAlchemy)));
        CT_TRACE(("CDataHistory: %d", sizeof(CDataHistory)));

        CT_TRACE(("CGiftData: %d", sizeof(CGiftData)));
        CT_TRACE(("CMuseData: %d", sizeof(CMuseData)));        
        CT_TRACE(("CEnemyAtkCityRoleData: %d", sizeof(CEnemyAtkCityRoleData)));
        CT_TRACE(("CFamilyDiceData: %d", sizeof(CFamilyDiceData)));
        CT_TRACE(("CWishData: %d", sizeof(CWishData)));
        CT_TRACE(("CSplendidAct: %d", sizeof(CSplendidAct)));
        CT_TRACE(("CPyramidActData: %d", sizeof(CPyramidActData)));
        CT_TRACE(("CPlayerDetailInfo: %d", sizeof(CPlayerDetailInfo)));
    }
public:
    unsigned int                _uiGID;

    int                         _iReputation;       //声望

    //阵形
    CPlayerMatrix               _stPlayerMatrix;

    //伙伴
    CPartnerData                _stUserPartner;

    //装备管理器(背包+仓库+人身上的装备)
    CEquipData                  _stUserEquip;

    //仓库+背包
    StorageData                 _stUserStorage;

    //主角技能
    CPlayerDBSkill              _stUserDBSkill;

    //主角装备
    CPlayerEquip                _stPlayerEquip;

    //占卜信息
    CUserDivineData             _stUserDivine;

    //卡片信息
    CUserCardData               _stUserCardData;

    //主角装备的卡片
    CPlayerWareCard             _stPlayerWareCard;

    //命运漩涡
    CCardVortex                 _stCardVortex;

    //魂器
    CPlayerSoulData             _stSoulData;

    //商店
    CShopData                   _stShopData;

    //魔药
    CDrugData                   _stDrugData;

    //魔晶开采
    CMineCrystalData            _stMineData;

    //竞技场数据（除排名外）
    CUserArenaData              _stUserArenaData;

    //帮派信息
    CUserClan                   _stUserClan;

    //上课系统
    CUserLessonData             _stUserLessonData;

    //炼金
    CUserAlchemy                _stUserAlchemy;

    //秘宝
    CTreasureData               _stTreasureData;

    //战力历史
    CDataHistory                _stBattleFightingHis;

    //礼包
    CGiftData                   _stGiftData;

    //冥想
    CMuseData                   _stMuseData;

    //坐骑
    CMountData                   _stMountData;

    //怪物攻城战数据
    CEnemyAtkCityRoleData       _stEnemyAtkCityRoleData;

    //家族闯关数据
    CFamilyDiceData             _stDiceData;

    //许愿池
    CWishData                   _stWishData;

    //精彩活动
    CSplendidAct                _stSplendidAct;

    //金字塔活动
    CPyramidActData             _stPyramidAct;
};

BEGIN_CODE_CONVERT(CPlayerDetailInfo)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_iReputation)
CODE_CONVERT(_stPlayerMatrix)
CODE_CONVERT(_stUserPartner)
CODE_CONVERT(_stUserEquip)
CODE_CONVERT(_stUserStorage)
CODE_CONVERT(_stUserDBSkill)
CODE_CONVERT(_stPlayerEquip)
CODE_CONVERT(_stUserDivine)
CODE_CONVERT(_stUserCardData)
CODE_CONVERT(_stPlayerWareCard)
CODE_CONVERT(_stCardVortex)
CODE_CONVERT(_stSoulData)
CODE_CONVERT(_stShopData)
CODE_CONVERT(_stDrugData)
CODE_CONVERT(_stMineData)
CODE_CONVERT(_stUserArenaData)
CODE_CONVERT(_stUserClan)
CODE_CONVERT(_stUserLessonData)
CODE_CONVERT(_stUserAlchemy)
CODE_CONVERT(_stTreasureData)
CODE_CONVERT(_stBattleFightingHis)
CODE_CONVERT(_stGiftData)
CODE_CONVERT(_stMuseData)
CODE_CONVERT(_stEnemyAtkCityRoleData)
CODE_CONVERT(_stWishData)
CODE_CONVERT(_stDiceData)
CODE_CONVERT(_stSplendidAct)
CODE_CONVERT(_stPyramidAct)
END_CODE_CONVERT(CPlayerDetailInfo)

class CQQMallLimitItem : public CTCodeObject
{
public:
    CQQMallLimitItem ()
    {
        _iExpiredTime = 0;
        _iBuiedNums = 0;
        _uiGoodsId = 0;
    }

    //相同的商品可能出现在多个时间段
    int _iExpiredTime;
    int _iBuiedNums;
    unsigned int _uiGoodsId;
};
BEGIN_CODE_CONVERT(CQQMallLimitItem)
CODE_CONVERT(_iExpiredTime)
CODE_CONVERT(_iBuiedNums)
CODE_CONVERT(_uiGoodsId)
END_CODE_CONVERT(CQQMallLimitItem)

//////////////////////////////////////////////////////////////////////////
class CUserQQMall : public CTCodeObject
{
public:
    CUserQQMall ()
    {
        Clear();
    }

    void Clear ()
    {
        _stLimitItems.Clear();
        _stBuiedMount.Clear();
    }

    void DelExpiedGoods (int iNowTime)
    {
        CTArray<unsigned int, MAX_LIMIT_GOODS_MEANWHILE> stToDels;
        for (int i = 0; i < _stLimitItems.Size(); ++i)
        {
            CQQMallLimitItem & stItem = _stLimitItems[i];
            if (stItem._iExpiredTime <= iNowTime)
            {
                stToDels.AddOneItem(stItem._uiGoodsId);
            }
        }

        for (int i = 0; i < stToDels.Size(); i++)
        {
            for (int k = 0; k < _stLimitItems.Size(); k++)
            {
                if (stToDels[i] == _stLimitItems[k]._uiGoodsId)
                {
                    _stLimitItems.DelOneItem(k);
                    break;
                }
            }
        }
    }

    int GetGoodsBuiedNums (unsigned int uiGoodsId)
    {
        for (int k = 0; k < _stLimitItems.Size(); k++)
        {
            if (uiGoodsId == _stLimitItems[k]._uiGoodsId)
            {
                return _stLimitItems[k]._iBuiedNums;
            }
        }

        return 0;
    }

    int CheckThenAddMount (unsigned int uiMountGoodsID)
    {
        if (_stBuiedMount.Size() == _stBuiedMount.GetCount())
        {
            return ERROR_MOUNT_SHOP_LIMIT;
        }

        for (int i = 0 ; i < _stBuiedMount.Size(); i++)
        {
            if (_stBuiedMount[i] == uiMountGoodsID)
            {
                return ERROR_MOUNT_REPEAT;
            }
        }

        _stBuiedMount.AddOneItem(uiMountGoodsID);
        return RET_OK;
    }

    int GetCanBuyMountCnt (unsigned int uiMountGoodsID)
    {
        for (int i = 0 ; i < _stBuiedMount.Size(); i++)
        {
            if (_stBuiedMount[i] == uiMountGoodsID)
            {
                return 0;
            }
        }

        return 1;
    }

    CTArray<CQQMallLimitItem, MAX_LIMIT_GOODS_MEANWHILE> _stLimitItems;
    CTArray <unsigned int , MAX_MOUNT_CAN_BUY> _stBuiedMount;
};
BEGIN_CODE_CONVERT(CUserQQMall)
CODE_CONVERT(_stLimitItems)
CODE_CONVERT(_stBuiedMount)
END_CODE_CONVERT(CUserQQMall)

//新手目标
class CNewbieTaskDetailData : public CTCodeObject
{
public:
    CNewbieTaskDetailData()
    {
        Clear();
    }

    void Clear()
    {
        _ucHasFinished = 0;
        _ucHasGetBonus = 0;
        _iNowCond1 = 0;
        _iNowCond2 = 0;
    }

public:
    unsigned char  _ucHasFinished;   //是否已经完成    
    unsigned char  _ucHasGetBonus;   //是否已经领奖
    int            _iNowCond1;   //完成状态1
    int            _iNowCond2;   //完成状态2
};
BEGIN_CODE_CONVERT(CNewbieTaskDetailData)
CODE_CONVERT(_ucHasFinished)
CODE_CONVERT(_ucHasGetBonus)
CODE_CONVERT(_iNowCond1)
CODE_CONVERT(_iNowCond2)
END_CODE_CONVERT(CNewbieTaskDetailData)

class CNewbieTaskUserData : public CTCodeObject
{
public:
    CNewbieTaskUserData()
    {
        Clear();
    }   

    void Clear()
    {
        _iRegisterTime = 0;
        _astTaskCond.Clear();
    }
     
public:
    int _iRegisterTime;                                                          //完成角色初始化的时间
    CTArray<unsigned char, MAX_NEWBIE_TASK_DAYS>                 _astHasGetDayBonus;   //是否已经领奖
    CTArray<CNewbieTaskDetailData, MAX_NEWBIE_TASK_CONFIG_COUNT> _astTaskCond;   //当前状态
};
BEGIN_CODE_CONVERT(CNewbieTaskUserData)
CODE_CONVERT(_iRegisterTime)
CODE_CONVERT(_astHasGetDayBonus)
CODE_CONVERT(_astTaskCond)
END_CODE_CONVERT(CNewbieTaskUserData)

//////////////////////////////////////////////////////////////////////////
#define MAX_LOGIN_GOLD_DAYS  3
class CUserLoginGold : public CTCodeObject
{
public:
    CUserLoginGold ()
    {
        Clear();
    }

    void Clear ()
    {
        _stGetNums.Clear();
    }

    int GetGoldCount (unsigned char ucDay, int iTodayOnlineSecs, int iHours)
    {
        int iMax = GetMaxNumsOfDay (ucDay);
        if (0 == iMax)
        {
            return 0;
        }

        //当日的已经领完了
        if (iMax <= _stGetNums[ucDay - 1])
        {
            return 0;
        }

        int iCount = 0;
        //23点登陆的, 不设置倒计时间, 直接可以领取. 
        if ((0 == _stGetNums[ucDay - 1]) && (23 == iHours || iTodayOnlineSecs > 3600))
        {
            iCount = iMax;
        }
        else
        {
            iCount = iMax / 2;
        }

        return iCount;
    }   

    void AddGoldNum (unsigned char ucDay, int iNums)
    {
        if (ucDay > MAX_LOGIN_GOLD_DAYS || ucDay < 1)
        {
            return ;
        }

        _stGetNums.m_iUsedCount = ucDay;
        _stGetNums[ucDay - 1] += iNums;        
    }

    int GetMaxNumsOfDay (unsigned char ucDay)
    {
        if (ucDay > MAX_LOGIN_GOLD_DAYS || ucDay < 1)
        {
            return 0;
        }
        
        int iGold[MAX_LOGIN_GOLD_DAYS] = {100, 100, 100};
        return iGold[ucDay - 1];
    }

    bool HasThisDayGet (unsigned char ucDay)
    {
        int iMax = GetMaxNumsOfDay (ucDay);
        if (0 == iMax)
        {
            return false;
        } 
        
        if (_stGetNums[ucDay - 1] == 0)
        {
            return false;
        }

        return true;
    }

    int GetDayStatus (unsigned char ucDay)
    {
        int iMax = GetMaxNumsOfDay (ucDay);
        if (0 == iMax)
        {
            return 0;   //这天不能领
        } 

        if (_stGetNums[ucDay - 1] == 0)
        {
            return 2;  // 还未领取过
        }

        if (_stGetNums[ucDay - 1] >= iMax)
        {
            return 3;  //已经领完了
        }

        return 1;  //领过一次
    }

    CTArray<int, MAX_LOGIN_GOLD_DAYS> _stGetNums;
};
BEGIN_CODE_CONVERT(CUserLoginGold)
CODE_CONVERT(_stGetNums)
END_CODE_CONVERT(CUserLoginGold)

//////////////////////////////////////////////////////////////////////////
class CPlayerDaySign : public CTCodeObject
{
public:
    CPlayerDaySign()
    {
        Clear();
    }

    void Clear ()
    {
        _chContinueCount = 0;
        _chContinueAward = 0;
        _iLastSignTime = 0;
        _stMonthlyCount.Clear();
        _stMonthlyAward.Clear();
    }

    virtual ~CPlayerDaySign()
    {
    }

public:
    char _chContinueCount;
    char _chContinueAward;
    int _iLastSignTime;
    CMonthlyReflushInt _stMonthlyCount; //签到每月计数
    CMonthlyReflushInt _stMonthlyAward; //累计签到奖励
};

BEGIN_CODE_CONVERT(CPlayerDaySign)
CODE_CONVERT(_chContinueCount)
CODE_CONVERT(_chContinueAward)
CODE_CONVERT(_iLastSignTime)
CODE_CONVERT(_stMonthlyCount)
CODE_CONVERT(_stMonthlyAward)
END_CODE_CONVERT(CPlayerDaySign)

//消费活动：消费返利和成长基金
class CPayActData : public CTCodeObject
{
public:
    CPayActData()
    {
        Clear();
    }

    void Clear()
    {
        _ucHasBuyGrowFund = 0;
        _ucGrowFundStat = 0;

        _stTodayPayQPoint.SetDefault(0);
        _iCanGetPayBackGold = 0;
    }

    //成长基金: 检查是否已经领取对应的成长基金
    bool HasGetPayFund(int iIndex)
    {
        if (iIndex < 0 || iIndex >= MAX_GROW_FUND_TYPE)
        {
            return true;
        }

        return (_ucGrowFundStat & 1 << iIndex);
    }

    //成长基金: 设置已经领取
    void SetHasGetPayFund(int iIndex)
    {
        if (iIndex < 0 || iIndex >= MAX_GROW_FUND_TYPE)
        {
            CT_ERROR((""));
            return;
        }

        _ucGrowFundStat |= 1 << iIndex;
    }

    //成长基金: 检查等级是否足够
    bool PayFundCheckLevel(unsigned short usLevel, int iIndex)
    {
        switch (iIndex)
        {
        case 0:
            return usLevel >= 25;
        case 1:
            return usLevel >= 30;
        case 2:
            return usLevel >= 35;
        case 3:
            return usLevel >= 40;
        case 4:
            return usLevel >= 45;
        case 5:
            return usLevel >= 50;
        default:
            return false;
        }
    }

    //成长基金: 获取可领取的数量
    int PayFundGetGoldCount(int iIndex)
    {
        switch (iIndex)
        {
        case 0:
            return 100;
        case 1:
            return 150;
        case 2:
            return 200;
        case 3:
            return 250;
        case 4:
            return 300;
        case 5:
            return 400;
        default:
            return 0;
        }
    }

    //消费返利：配置：计算累计消费对应的返利
    static int GetPayBackGoldConfig(unsigned char ucVipLevel, int iTotalQPoint)
    {
        int iCount = 0;

        if (ucVipLevel < 2)
        {
            return 0;
        }
        
        if (ucVipLevel >= 2 && iTotalQPoint >= 100)
        {
            iCount += 30;
        }

        if (ucVipLevel >= 3 && iTotalQPoint >= 300)
        {
            iCount += 50;
        }

        if (ucVipLevel >= 4 && iTotalQPoint >= 1000)
        {
            iCount += 120;
        }

        if (ucVipLevel >= 6 && iTotalQPoint >= 3000)
        {
            iCount += 300;
        }

        return iCount;
    }

    //消费返利：增加消费Q点数: ucOldVipLevel:消费前的VIP等级
    void AddQPoint(unsigned char ucOldVipLevel, int iQPoint, int iNowTime)
    {
        if (!CTTimeUtils::IsSameDay(_stTodayPayQPoint._iLastUpdateTime, iNowTime))
        {
            _iCanGetPayBackGold += GetPayBackGoldConfig(ucOldVipLevel, _stTodayPayQPoint._stData);
            _stTodayPayQPoint.Clear();
        }

        _stTodayPayQPoint.Add(iQPoint, iNowTime, 0);
    }

    //消费返利：获取今日可领取的符石数
    int GetTodayCanGetPayBackGold(unsigned char ucVipLevel, int iNowTime)
    {
        if (CTTimeUtils::IsSameDay(_stTodayPayQPoint._iLastUpdateTime, iNowTime))
        {
            return _iCanGetPayBackGold;
        }

        return _iCanGetPayBackGold + GetPayBackGoldConfig(ucVipLevel, _stTodayPayQPoint._stData);
    }

    //消费返利：获取明日可领取的符石数(不累计未领取的)
    int GetTomorrowCanGetPayBackGold(unsigned char ucVipLevel, int iNowTime)
    {
        if (CTTimeUtils::IsSameDay(_stTodayPayQPoint._iLastUpdateTime, iNowTime))
        {
            return GetPayBackGoldConfig(ucVipLevel, _stTodayPayQPoint._stData);
        }

        return 0;
    }

    //消费返利: 设置领取了消费返利
    void SetGetPayBackGold(int iNowTime)
    {
        if (!CTTimeUtils::IsSameDay(_stTodayPayQPoint._iLastUpdateTime, iNowTime))
        {
            _stTodayPayQPoint.Clear();
        }

        _iCanGetPayBackGold = 0;
    }

    //成长基金
    unsigned char _ucHasBuyGrowFund;        //是否已经购买成长基金
    unsigned char _ucGrowFundStat;          //成长基金领取状态

    //消费返利
    CDailyReflushInt    _stTodayPayQPoint;  //今日累计支付Q点
    int                 _iCanGetPayBackGold;//累计可领取的符石

};

BEGIN_CODE_CONVERT(CPayActData)
CODE_CONVERT(_ucHasBuyGrowFund)
CODE_CONVERT(_ucGrowFundStat)
CODE_CONVERT(_stTodayPayQPoint)
CODE_CONVERT(_iCanGetPayBackGold)
END_CODE_CONVERT(CPayActData)

//////////////////////////////////////////////////////////////////////////
class CDayWishItem : public CTCodeObject
{
public:
    CDayWishItem()
    {
        Clear();
    }

    void Clear ()
    {
        _chMask = 0;
        _iItemID = 0;
    }

    virtual ~CDayWishItem()
    {
    }

public:
    char _chMask;
    int _iItemID;
};

BEGIN_CODE_CONVERT(CDayWishItem)
CODE_CONVERT(_chMask)
CODE_CONVERT(_iItemID)
END_CODE_CONVERT(CDayWishItem)

//////////////////////////////////////////////////////////////////////////
class CPlayerDayWish : public CTCodeObject
{
public:
    CPlayerDayWish()
    {
        Clear();
    }

    void Clear ()
    {
        _iLastUpdateTime = 0;
        _stWishTimes.Clear();
        _astWishItem.Clear();
    }

    virtual ~CPlayerDayWish()
    {
    }

public:
    int _iLastUpdateTime;
    CDailyReflushChar _stWishTimes;
    CTLib::CTArray<CDayWishItem, MAX_DAY_WISH_ITEM_COUNT> _astWishItem;
};

BEGIN_CODE_CONVERT(CPlayerDayWish)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stWishTimes)
CODE_CONVERT(_astWishItem)
END_CODE_CONVERT(CPlayerDayWish)

//////////////////////////////////////////////////////////////////////////
class CQQFriendData : public CTCodeObject
{
public:
    CQQFriendData()
    {
        Clear();
    }

    void Clear ()
    {
        _chLvlNum = 0;
        _chInviteNum = 0;
        _chAwardMask = 0;
        _shPayCount = 0;
        _iCertiCount = 0;
        _uiInviterGID = 0;
        _stDayInvite.Clear();
        _auiInviteGID.Clear();
    }

    virtual ~CQQFriendData()
    {
    }

public:
    //注意以下使用小范围值 应避免溢出
    char _chLvlNum; //达到特定等级的被邀请人数
    char _chInviteNum; //累计邀请人数 只在被邀请者创建角色时候累加
    char _chAwardMask; //奖励掩码
    short _shPayCount; //被邀请者累计消费Q点
    int _iCertiCount; //奖券数
    unsigned int _uiInviterGID; //邀请者GID
    CDailyReflushChar _stDayInvite; //每日邀请
    CTLib::CTArray<unsigned int, FRIEND_QQ_INVITE_PAY_ANY_COUNT> _auiInviteGID; //消费任意Q点的人的GID
};

BEGIN_CODE_CONVERT(CQQFriendData)
CODE_CONVERT(_chLvlNum)
CODE_CONVERT(_chInviteNum)
CODE_CONVERT(_chAwardMask)
CODE_CONVERT(_shPayCount)
CODE_CONVERT(_iCertiCount)
CODE_CONVERT(_uiInviterGID)
CODE_CONVERT(_stDayInvite)
CODE_CONVERT(_auiInviteGID)
END_CODE_CONVERT(CQQFriendData)

//宝箱争夺战
//////////////////////////////////////////////////////////////////////////
class CFightForBoxData : public CTCodeObject
{
public:
    CFightForBoxData()
    {
        Clear();
    }
    void Clear()
    {
        _ucHasBegin = 0;
        _ucHasBuyEyeCount = 0;
        _ucLeftEyeCount = 0;
        _ucBuyEyeCount = 0;
        _ucHasUsedEyeCount = 0;
    }
    int GetEyeCount()
    {
        return _ucBuyEyeCount + _ucLeftEyeCount;
    }
    unsigned char _ucHasBegin;                                              //是否已经开始
    CTArray<unsigned char, MAX_FIGHT_FOR_BOX_BOX_COUNT> _aucBoxStat;        //箱子状态
    CTArray<int, MAX_FIGHT_FOR_BOX_ROLE_COUNT - 1> _aiAllNPC;                //NPC ID
    CTArray<unsigned char, MAX_FIGHT_FOR_BOX_ROLE_COUNT - 1> _aucNPCStop2RoundStat;                //NPC 等待回合的状态
    CTArray<short, MAX_FIGHT_FOR_BOX_ROLE_COUNT> _ashAllPoint;      //所有人的积分, 0位置是主角的积分
    unsigned char _ucHasBuyEyeCount;                                        //已经购买的慧眼次数            
    unsigned char _ucLeftEyeCount;                                          //剩余的慧眼次数
    unsigned char _ucBuyEyeCount;                                           //购买且还未用完的慧眼次数
    unsigned char _ucHasUsedEyeCount;                                       //已经使用的次数
};
BEGIN_CODE_CONVERT(CFightForBoxData)
CODE_CONVERT(_ucHasBegin)
CODE_CONVERT(_aucBoxStat)
CODE_CONVERT(_aiAllNPC)
CODE_CONVERT(_aucNPCStop2RoundStat)
CODE_CONVERT(_ashAllPoint)
CODE_CONVERT(_ucHasBuyEyeCount)
CODE_CONVERT(_ucLeftEyeCount)
CODE_CONVERT(_ucBuyEyeCount)
CODE_CONVERT(_ucHasUsedEyeCount)
END_CODE_CONVERT(CFightForBoxData)

//////////////////////////////////////////////////////////////////////////
class CPlayerFightEnd : public CTCodeObject
{
public:
    CPlayerFightEnd()
    {
        Clear();
    }

    void Clear ()
    {
        _chAwardNum = 0;
        _iLastEndTime = 0;
    }

    virtual ~CPlayerFightEnd()
    {
    }

public:
    char _chAwardNum;   //奖励次数
    int _iLastEndTime;  //上次活动结束时间
};
BEGIN_CODE_CONVERT(CPlayerFightEnd)
CODE_CONVERT(_chAwardNum)
CODE_CONVERT(_iLastEndTime)
END_CODE_CONVERT(CPlayerFightEnd)

//////////////////////////////////////////////////////////////////////////
//悬赏令任务
class CRewardTaskData : public CTCodeObject
{
public:
    CRewardTaskData()
    {
        
    }

    void Clear()
    {
        _ucTaskType = 0;
        _ucStat = 0;
        _iPublishTime = 0;
        _uiAcceptGID = 0;
    }

public:
    unsigned char _ucTaskType;      //任务类型
    unsigned char _ucStat;          //状态  0: 未完成 1: 已完成
    int             _iPublishTime;  //发布时间
    unsigned int    _uiAcceptGID;   //接取者的GID
};
BEGIN_CODE_CONVERT(CRewardTaskData)
CODE_CONVERT(_ucTaskType)
CODE_CONVERT(_ucStat)
CODE_CONVERT(_iPublishTime)
CODE_CONVERT(_uiAcceptGID)
END_CODE_CONVERT(CRewardTaskData)

class CRewardTask : public CTCodeObject
{
public:
    CRewardTask()
    {
        _stHasPublishCount.Clear();
        _stHasAcceptCount.Clear();
        _stHasPublishCount.SetDefault(0);
        _stHasAcceptCount.SetDefault(0);
    }

    CDailyReflushChar _stHasPublishCount; //已发布数量
    CDailyReflushChar _stHasAcceptCount;  //已接取数量
    CTArray<CRewardTaskData, MAX_REWARD_TASK_PER_ROLE> _astRewardTasks;
};
BEGIN_CODE_CONVERT(CRewardTask)
CODE_CONVERT(_stHasPublishCount)
CODE_CONVERT(_stHasAcceptCount)
CODE_CONVERT(_astRewardTasks)
END_CODE_CONVERT(CRewardTask)

#define NEWZONE_SALES_ITEM_CNT  6
#define NEWZONE_SALES_OPEN_LEVEL  17
class CNewZoneSales : public CTCodeObject
{
public:
    CNewZoneSales()
    {
        Clear();
    }

    void Clear ()
    {
        _astGainedItem.Clear();
        _bGainedBonus = false;
    }

    bool HasGained (CDropItemData & stItem)
    {
        for (int k = 0; k < _astGainedItem.Size(); k++)
        {
            if (_astGainedItem[k] == stItem)
            {
                return true;
            }            
        }

        return false;
    }

    int AddGainedItem (CDropItemData & stItem)
    {
        if (_astGainedItem.Size() >= NEWZONE_SALES_ITEM_CNT)
        {
            return ERROR_NEWSALES_ITEM_REP;
        }

        _astGainedItem.AddOneItem(stItem);
        return RET_OK;
    }

    bool HasBuyAllItem ()
    {
        return (_astGainedItem.Size() == NEWZONE_SALES_ITEM_CNT);
    }

    unsigned char _bGainedBonus;
    CTArray<CDropItemData, NEWZONE_SALES_ITEM_CNT> _astGainedItem;
};

BEGIN_CODE_CONVERT(CNewZoneSales)
CODE_CONVERT(_astGainedItem)
CODE_CONVERT(_bGainedBonus)
END_CODE_CONVERT(CNewZoneSales)


//学院杯个从数据
class CAcaCupGuessList : public CTCodeObject //决赛竞猜数据 
{
public:
    enum ACA_CUP_GUESS_STAT
    {
        ACA_CUP_GUESS_NULL = 0, //未参与
        ACA_CUP_GUESS_WAIT = 1, //未出结果
        ACA_CUP_GUESS_WIN = 2, //胜利
        ACA_CUP_GUESS_LOSS = 3, //失败
    };

    CAcaCupGuessList()
    {
        _ucGuessStat = ACA_CUP_GUESS_NULL;
        _uiDestGID = 0;
        _uiGetSilverCount = 0;
    }

    unsigned char _ucGuessStat;   //竞猜状态
    unsigned short _usGuessLevel; //竞猜时的等级
    unsigned int _uiDestGID;   //目标
    unsigned int _uiGetSilverCount; //获得的银币
};
BEGIN_CODE_CONVERT(CAcaCupGuessList)
    CODE_CONVERT(_ucGuessStat)
    CODE_CONVERT(_usGuessLevel)
    CODE_CONVERT(_uiDestGID)
    CODE_CONVERT(_uiGetSilverCount)
END_CODE_CONVERT(CAcaCupGuessList)

class CAcaCupUserData : public CTCodeObject
{
public:
    int _iNowAttendSeq;               //当前参与的学院杯序列号
    CTArray<CAcaCupGuessList, MAX_ACA_CAP_SECOND_ROUND> _astGuessList; //竞猜记录
};
BEGIN_CODE_CONVERT(CAcaCupUserData)
    CODE_CONVERT(_iNowAttendSeq)
    CODE_CONVERT(_astGuessList)
END_CODE_CONVERT(CAcaCupUserData)

//任务集市
class CMarketTask : public CTCodeObject
{
public:
    CMarketTask()
    {
        Clear();
    }

    void Clear ()
    {
        _ucIsFromMarket = false;
        _ucHasGetAward = false;
        _ucHasFinish = false;
        _uiTaskId = 0;
    }

    bool NeedCheckStatus ()
    {
        if (_ucIsFromMarket && (false == _ucHasFinish))
        {
            return true;
        }

        return false;
    }

    unsigned char _ucIsFromMarket;   //是否通过集市任务进入的
    unsigned char _ucHasGetAward;    //是否已经领取过奖励
    unsigned char _ucHasFinish;      //任务是否已完成
    unsigned int _uiTaskId;          //系统内的任务ID
};
BEGIN_CODE_CONVERT(CMarketTask)
CODE_CONVERT(_ucIsFromMarket)
CODE_CONVERT(_ucHasGetAward)
CODE_CONVERT(_ucHasFinish)
CODE_CONVERT(_uiTaskId)
END_CODE_CONVERT(CMarketTask)

enum EN_FASION_POS
{
    FASION_POS_NONE  = 0,
    FASION_POS_WING = 1,
    FASION_POS_DRESS = 2
};
//时装
class CUserFashion : public CTCodeObject
{
public:
    CUserFashion()
    {
        Clear();
    }

    void Clear ()
    {
        _ucWingHidden = 0;
        _ucDressHidden = 0;
        _uiNowWing = 0;
        _uiNowDress = 0;
        _uiGainedFashionCnt = 0;
        _astWingBag.Clear();
        _astDressBag.Clear();
    }

    int GetWingEndTime (unsigned short usWingID)
    {
        for (int i = 0; i < _astWingBag.Size(); i++)
        {
            if (usWingID == _astWingBag[i]._uiItemID)
            {
                return _astWingBag[i]._iInvalidTime;
            }
        }

        return 0;
    }

    int GetDressEndTime (unsigned short usDressID)
    {
        for (int i = 0; i < _astDressBag.Size(); i++)
        {
            if (usDressID == _astDressBag[i]._uiItemID)
            {
                return _astDressBag[i]._iInvalidTime;
            }
        }

        return 0;
    }

    unsigned char _ucWingHidden;
    unsigned char _ucDressHidden;
    unsigned int _uiGainedFashionCnt;
    unsigned int _uiNowWing;
    unsigned int _uiNowDress;
    CTArray<StorageItemData, MAX_WING_BAG_SIZE> _astWingBag;
    CTArray<StorageItemData, MAX_DRESS_BAG_SIZE> _astDressBag;    
};
BEGIN_CODE_CONVERT(CUserFashion)
CODE_CONVERT(_ucWingHidden)
CODE_CONVERT(_ucDressHidden)
CODE_CONVERT(_uiGainedFashionCnt)
CODE_CONVERT(_uiNowWing)
CODE_CONVERT(_uiNowDress)
CODE_CONVERT(_astWingBag)    
CODE_CONVERT(_astDressBag)
END_CODE_CONVERT(CUserFashion)

//奖励找回
class CPlayerRewardBackUnit : public CTCodeObject
{
public:
    CPlayerRewardBackUnit()
    {
        Clear();
    }

    void Clear ()
    {
        _iActMask = 0;
        _iDayZeroTime = 0;
    }

    virtual ~CPlayerRewardBackUnit()
    {
    }

    int GetDayZeroTime() const {return _iDayZeroTime;}

public:
    int _iActMask;
    int _iDayZeroTime;
};
BEGIN_CODE_CONVERT(CPlayerRewardBackUnit)
CODE_CONVERT(_iActMask)
CODE_CONVERT(_iDayZeroTime)
END_CODE_CONVERT(CPlayerRewardBackUnit)

typedef CTLib::CTArray<int, MAX_REWARD_BACK_DAY_COUNT * 2>  T_REWARD_BACK_LIST;

class CPlayerRewardBack : public CTCodeObject
{
public:
    CPlayerRewardBack()
    {
        Clear();
    }

    void Clear ()
    {
        _iOpenZeroTime = 0;
        _astList.Clear();
    }

    virtual ~CPlayerRewardBack()
    {
    }

    int FindUnit(int iDayZeroTime)
    {
        for (int i = 0; i < _astList.Size(); ++i)
        {
            if (_astList[i].GetDayZeroTime() == iDayZeroTime)
            {
                return i;
            }
        }
        return -1;
    }

    CPlayerRewardBackUnit& GetUnit(int iIndex)
    {
        return _astList[iIndex];
    }

public:
    int _iOpenZeroTime;
    CTRankArray<CPlayerRewardBackUnit, MAX_REWARD_BACK_DAY_COUNT> _astList;
};
BEGIN_CODE_CONVERT(CPlayerRewardBack)
CODE_CONVERT(_iOpenZeroTime)
CODE_CONVERT(_astList)
END_CODE_CONVERT(CPlayerRewardBack)

//////////////////////////////////////////////////////////////////////////
class CPlayerLoginReward : public CTCodeObject
{
public:
    CPlayerLoginReward()
    {
        Clear();
    }

    void Clear ()
    {
        _chLoginMask = 0;
        _chRewardMask = 0;
        _iOpenZeroTime = 0;
    }

    virtual ~CPlayerLoginReward()
    {
    }

public:
    char _chLoginMask;
    char _chRewardMask;
    int  _iOpenZeroTime;
};
BEGIN_CODE_CONVERT(CPlayerLoginReward)
CODE_CONVERT(_chLoginMask)
CODE_CONVERT(_chRewardMask)
CODE_CONVERT(_iOpenZeroTime)
END_CODE_CONVERT(CPlayerLoginReward)

//////////////////////////////////////////////////////////////////////////
enum ENM_ACT_STORAGE_MODULE_TAG //活动扩展存储模块ID
{
    ENM_ACT_STORAGE_LUCKY_DIAL = 1, //精彩活动中的幸运转盘
};

class CPlayerActStorage : public CTCodeObject
{
public:
    CPlayerActStorage()
    {
        Clear();
    }

    void Clear ()
    {
        _astLuckyDial.Clear();
    }

    virtual ~CPlayerActStorage()
    {
    }

    bool CheckLuckyDialOneTime()
    {
        //先判断是否存在红色彗星 若有则提示收取
        for (int i = 0; i < _astLuckyDial.Size(); ++i)
        {
            if (_astLuckyDial[i]._usItemConfigID == 29 &&
                _astLuckyDial[i]._ucItemType == ITEM_TYPE_PARTNER)
            {
                return false;
            }
        }

        //本来只判断98个上限但是策划有可能配一次给2个 这里统一限制为89
        for (int i = 0; i < _astLuckyDial.Size(); ++i)
        {
            if (_astLuckyDial[i]._usItemConfigID > 0 &&
                _astLuckyDial[i]._iItemCount > MAX_LUCKY_DIAL_ITEM_STACK - 10)
            {
                return false; //只要有一个达到堆叠上限-10
            }
        }
        
        return true;
    }

    bool CheckLuckyDialTenTime()
    {
        //先判断是否存在红色彗星 若有则提示收取
        for (int i = 0; i < _astLuckyDial.Size(); ++i)
        {
            if (_astLuckyDial[i]._usItemConfigID == 29 &&
                _astLuckyDial[i]._ucItemType == ITEM_TYPE_PARTNER)
            {
                return false;
            }
        }

        for (int i = 0; i < _astLuckyDial.Size(); ++i)
        {
            if (_astLuckyDial[i]._usItemConfigID > 0 &&
                _astLuckyDial[i]._iItemCount > MAX_LUCKY_DIAL_ITEM_STACK - 10)
            {
                return false; //只要有一个达到堆叠上限-10
            }
        }
        
        return true;
    }

public:
    CTLib::CTArray<CDropItemData, MAX_SPLENDID_LUCKY_DIAL_ITEM_COUNT> _astLuckyDial; //幸运转盘物品背包
};
BEGIN_CODE_CONVERT(CPlayerActStorage)
CODE_CONVERT(_astLuckyDial)
END_CODE_CONVERT(CPlayerActStorage)

//////////////////////////////////////////////////////////////////////////
class CPlayerDetailInfoEx1 : public CTCodeObject
{
public:
    CPlayerDetailInfoEx1()
    {
        Clear();
    }

    void Clear()
    {
        _stUserMall.Clear();
        _iLoginDayCnt = 0;
        _iLastCalcDayTime = 0;
        _stLoginGold.Clear();
        _stUserDaySign.Clear();
        _stUserDayWish.Clear();
        _stPayActData.Clear();
        _stNewbieTaskUserData.Clear();
        _stFightForBox.Clear();
        _stQQFriend.Clear();
        _stFightEnd.Clear();        
        _stMount.Clear();
        _stNewSales.Clear ();
        _stMarketTask.Clear();
        _stUserFasion.Clear();
        _stRewardBack.Clear();
        _stLoginReward.Clear();
        _stActStorage.Clear();
        _stSplendidActEx1.Clear();
    }

    static void TraceSize()
    {
        CT_TRACE(("CUserQQMall %d", sizeof(_stUserMall)));
        CT_TRACE(("CNewbieTaskUserData %d", sizeof(CNewbieTaskUserData)));
        CT_TRACE(("CAcaCupUserData %d", sizeof(CAcaCupUserData)));
        CT_TRACE(("CPlayerDetailInfoEx1 %d", sizeof(CPlayerDetailInfoEx1)));
    }

    unsigned int _uiGID;
    
    int     _iLoginDayCnt;       //当前是登录的第几天(自然日).使用前需要先调用 CRoleMgr::UpdateLoginDays 处理跨天的情况
    int     _iLastCalcDayTime;   //上次计算登陆天数的时间.(处理跨天计算用)

    CUserQQMall         _stUserMall;
    CUserLoginGold      _stLoginGold;
    CPlayerDaySign      _stUserDaySign;//每日签到数据
    CPlayerDayWish      _stUserDayWish;//每日许愿数据
    CPayActData         _stPayActData; //消费相关活动

    CNewbieTaskUserData _stNewbieTaskUserData; //新手目标

    CFightForBoxData    _stFightForBox; //宝箱争夺战

    CQQFriendData       _stQQFriend; //QQ好友邀请
    
    CMountData _stMount;
    CPlayerFightEnd     _stFightEnd; //一战到底

    CRewardTask         _stRewardTask; //悬赏令任务

    CNewZoneSales       _stNewSales;

    CAcaCupUserData     _stAcaCupUserData; //学院杯数据

    CMarketTask         _stMarketTask;
   
    CUserFashion        _stUserFasion;

    CPlayerRewardBack   _stRewardBack;  //奖励找回

    CPlayerLoginReward  _stLoginReward; //登录奖励

    CPlayerActStorage   _stActStorage; //用于活动的扩展存储

    CSplendidActEx1     _stSplendidActEx1;
};
BEGIN_CODE_CONVERT(CPlayerDetailInfoEx1)
CODE_CONVERT(_stUserMall)
CODE_CONVERT(_stLoginGold)
CODE_CONVERT(_iLoginDayCnt)
CODE_CONVERT(_iLastCalcDayTime)
CODE_CONVERT(_stUserDaySign)
CODE_CONVERT(_stUserDayWish)
CODE_CONVERT(_stPayActData)
CODE_CONVERT(_stNewbieTaskUserData)
CODE_CONVERT(_stFightForBox)
CODE_CONVERT(_stQQFriend)
CODE_CONVERT(_stFightEnd)
CODE_CONVERT(_stRewardTask)
CODE_CONVERT(_stNewSales)
CODE_CONVERT(_stMount)
CODE_CONVERT(_stAcaCupUserData)
CODE_CONVERT(_stMarketTask)
CODE_CONVERT(_stUserFasion)
CODE_CONVERT(_stRewardBack)
CODE_CONVERT(_stLoginReward)
CODE_CONVERT(_stActStorage)
CODE_CONVERT(_stSplendidActEx1)
END_CODE_CONVERT(CPlayerDetailInfoEx1)

//////////////////////////////////////////////////////////////////////////

//花园用
enum GARDEN_LAND_CONTENT
{
    LAND_EMPTY = 0,
    LAND_FLOWER = 1,
    LAND_BOX = 2,
};

//花园：土地
class CGardenLandData : public CTCodeObject
{
public:
    CGardenLandData()
    {
        _ucLandLevel = 0;
        _ucLandContent = LAND_EMPTY;

        _ucFlowerID = 0;
        _usPartnerID = 0;
        _iPlantTime = 0;
        _ucHasGrown = 0;
    }

    int GetPickTime(char chGoblinCount) const
    {
        if (_ucHasGrown != 0)
        {
            return 0;
        }

        return (_iPlantTime + GARDEN_PICK_TIME + chGoblinCount * GARDEN_ADD_SECEND_PER_GOBLIN);
    }

public:
    unsigned char _ucLandLevel;         //土地等级
    unsigned char _ucLandContent;       //土地上的物品(空、花、宝箱)

    //种花相关
    unsigned char  _ucFlowerID;
    unsigned short _usPartnerID;
    int            _iPlantTime;         //种植时间
    unsigned char  _ucHasGrown;         //是否已经成熟, 主要用于加速
};

BEGIN_CODE_CONVERT(CGardenLandData)
CODE_CONVERT(_ucLandLevel)
CODE_CONVERT(_ucLandContent)
CODE_CONVERT(_ucFlowerID)
CODE_CONVERT(_usPartnerID)
CODE_CONVERT(_iPlantTime)
CODE_CONVERT(_ucHasGrown)
END_CODE_CONVERT(CGardenLandData)

//花园数据
class CUesrGardenData : public CTCodeObject
{
public:
    CUesrGardenData()
    {
        _uiGID = 0;

        _astLand.Clear();
        _astHelpFriendGID.Clear();
        _astBeenHelpFriendGID.Clear();
        _iLastAddBeenHelpFriendTime = 0;
        _iLastAddHelpFriendTime = 0;

        _chHoeCount = 0;
        _shSeedCount = 0;
        _chTodayBuySeedCount = 0;
        _iLastBuySeedTime = 0;
        _chAcornsCount = 0;
        _iLastUseAcornsTime = 0;
        _chTodayBuyHoeCount = 0;
        _iLastBuyHoeTime = 0;

        _chNowGoblinCount = 0;
        _chHoeOnLandCount = 0;
        _iLastFlushGoblinTime = 0;
        _iGoblinAppearTime = 0;

        _iBossDisappearTime = 0;

        _iBeginSleepTime = 0;
        _iNewSleepTime = 0;
        _iNewSleepTimeValid = 0;

        _iLastAddHelpFriendTime = 0;
        _iLastAddBeenHelpFriendTime = 0;

        _ucHasAccessGarden = 0;
        _ucHasForceFlushGoblin = 0;

        _stHasSpeedGrowTimeCount.SetDefault(0);
        _stHasDigBoxCount.SetDefault(0);

        _iLastSeekHelpTime = 0;
    }

    bool HasGoblin(int iNowTime) const
    {
        bool bHasGoblin = false;
        if (iNowTime >= _iGoblinAppearTime
            && iNowTime < _iGoblinAppearTime + GARDEN_GOBLIN_DISAPPEAR_TIME)
        {
            bHasGoblin = true;
        }

        return bHasGoblin;
    }

    bool HasBoss(int iNowTime) const
    {
        return iNowTime < _iBossDisappearTime;
    }

    bool HasCatchGoblinToday(unsigned int uiFriendGID, int iNow)
    {
        if (!CTTimeUtils::IsSameDay(iNow, _iLastAddHelpFriendTime, DATA_RESET_SEC_OF_DAY))
        {
            return false;
        }

        for (int i = 0; i < _astHelpFriendGID.Size(); ++i)
        {
            if (uiFriendGID == _astHelpFriendGID[i])
            {
                return true;
            }
        }

        return false;
    }

    char GetGoblinCount(bool bHasGoblin) const
    {
        return bHasGoblin ? _chNowGoblinCount : 0;
    }

    char GetHoeCount() const
    {
        return _chHoeCount;
    }

    char GetAcornsCount(int iNowTime) const
    {
        if (!CTTimeUtils::IsSameDay(iNowTime, _iLastUseAcornsTime, DATA_RESET_SEC_OF_DAY))
        {
            return GARDEN_MAX_ACORNS_COUNT;
        }
        else
        {
            return _chAcornsCount;
        }
    }

    bool IsValidLandPos(unsigned char ucPos)
    {
        if (ucPos >= MAX_GARDEN_LAND)
        {
            return false;
        }
        return true;
    }

    int GetSleepTime(int iNowTime) const
    {
        if (_iNewSleepTimeValid != -1 && iNowTime > _iNewSleepTimeValid)
        {
            return _iNewSleepTime;
        }

        return _iBeginSleepTime;
    }

    int GetSeedCount() const
    {
        return _shSeedCount;
    }

    int GetTodayBuyHoeTimes(int iNowTime) const
    {
        if (CTTimeUtils::IsSameDay(iNowTime, _iLastBuyHoeTime, DATA_RESET_SEC_OF_DAY))
        {
            return _chTodayBuyHoeCount;
        }

        return 0;
    }

    int GetTodayBuySeedTimes(int iNowTime) const
    {
        if (CTTimeUtils::IsSameDay(iNowTime, _iLastBuySeedTime, DATA_RESET_SEC_OF_DAY))
        {
            return _chTodayBuySeedCount;
        }

        return 0;
    }

public:
    unsigned int _uiGID;    //(不入库)

    CTLib::CTArray<CGardenLandData, MAX_GARDEN_LAND> _astLand;

    char _chHoeCount;                  //挖宝锄数量
    short _shSeedCount;                //种子数量
    char _chTodayBuySeedCount;          //当日购买种子的次数
    int _iLastBuySeedTime;              //最后一次购买种子的时间
    char _chAcornsCount;              //橡果数量
    int _iLastUseAcornsTime;           //最后一次使用橡果的时间
    char _chTodayBuyHoeCount;          //今天购买的挖宝锄次数
    int _iLastBuyHoeTime;              //最后一次购买挖宝锄的时间

    //地精相关
    char _chNowGoblinCount;             //当前地精数量
    char _chHoeOnLandCount;             //在地上的藏宝锄数量
    int _iLastFlushGoblinTime;          //最后一次地精刷新时间
    int _iGoblinAppearTime;             //地精出现的时间

    //BOSS相关
    int _iBossDisappearTime;            //BOSS消失时间

    //种植休眠
    int _iBeginSleepTime;               //开始休眠时间，从0开始，到24点
    int _iNewSleepTime;                 //新设置的休眠时间
    int _iNewSleepTimeValid;            //新设置的休眠时间生效开始时间

    //关系
    CTLib::CTArray<unsigned int, GARDEN_MAX_FRIEND_LIST> _astHelpFriendGID;            //帮助列表
    int _iLastAddHelpFriendTime;
    CTLib::CTArray<unsigned int, GARDEN_MAX_FRIEND_LIST> _astBeenHelpFriendGID;        //被帮助列表
    int _iLastAddBeenHelpFriendTime;

    unsigned char _ucHasAccessGarden;   //自己已经访问过花园,别人才能访问
    unsigned char _ucHasForceFlushGoblin; //是否已经强制刷新过地精

    CDailyReflushUChar _stHasSpeedGrowTimeCount;  //已经加速的次数  
    CDailyReflushUChar _stHasDigBoxCount;  //已经挖宝的次数 

    int                 _iLastSeekHelpTime; //最后一次求助的时间(不入库)
};

BEGIN_CODE_CONVERT(CUesrGardenData)
CODE_CONVERT(_astLand)

CODE_CONVERT(_chHoeCount)
CODE_CONVERT(_shSeedCount)
CODE_CONVERT(_chTodayBuySeedCount)
CODE_CONVERT(_iLastBuySeedTime)
CODE_CONVERT(_chAcornsCount)
CODE_CONVERT(_iLastUseAcornsTime)
CODE_CONVERT(_chTodayBuyHoeCount)
CODE_CONVERT(_iLastBuyHoeTime)

CODE_CONVERT(_chNowGoblinCount)
CODE_CONVERT(_chHoeOnLandCount)
CODE_CONVERT(_iLastFlushGoblinTime)
CODE_CONVERT(_iGoblinAppearTime)

CODE_CONVERT(_iBossDisappearTime)

CODE_CONVERT(_iBeginSleepTime)
CODE_CONVERT(_iNewSleepTime)
CODE_CONVERT(_iNewSleepTimeValid)

CODE_CONVERT(_astHelpFriendGID)
CODE_CONVERT(_iLastAddHelpFriendTime)
CODE_CONVERT(_astBeenHelpFriendGID)
CODE_CONVERT(_iLastAddBeenHelpFriendTime)

CODE_CONVERT(_ucHasAccessGarden)
CODE_CONVERT(_ucHasForceFlushGoblin)

CODE_CONVERT(_stHasSpeedGrowTimeCount)
CODE_CONVERT(_stHasDigBoxCount)
END_CODE_CONVERT(CUesrGardenData)

//好友数据
class CPlayerFriendData : public CTCodeObject
{
public:
    CPlayerFriendData()
    {
        Clear();
    }

    void Clear()
    {
        _astFriendList.Clear();
        _astTwoSideFriendList.Clear();
        _astBlackFriendList.Clear();
        _astRecentFriendList.Clear();
        _astEnemyFriendList.Clear();
    }

    bool IsFriend(unsigned int uiGID)
    {
        for (int i = 0; i < _astFriendList.Size(); ++i)
        {
            if (uiGID == _astFriendList[i])
            {
                return true;
            }
        }

        return false;
    }

    bool IsInBlack(unsigned int uiGID)
    {
        for (int i = 0; i < _astBlackFriendList.Size(); ++i)
        {
            if (uiGID == _astBlackFriendList[i])
            {
                return true;
            }
        }

        return false;
    }

    bool IsTowSideFriend(unsigned int uiGID)
    {
        for (int i = 0; i < _astTwoSideFriendList.Size(); ++i)
        {
            if (uiGID == _astTwoSideFriendList[i])
            {
                return true;
            }
        }

        return false;
    }

    void AddRecentFriend(unsigned int uiGID)
    {
        //如果已经存在
        for (int i = 0; i < _astRecentFriendList.Size(); ++i)
        {
            if (_astRecentFriendList[i] == uiGID)
            {
                for (int j = i; j > 0; --j)
                {
                    _astRecentFriendList[j] = _astRecentFriendList[j - 1];
                }

                _astRecentFriendList[0] = uiGID;
                return;
            }
        }

        //如果不存在
        if (_astRecentFriendList.GetCount() != _astRecentFriendList.Size())
        {
            _astRecentFriendList.AddOneItem(0);
        }

        for (int i = _astRecentFriendList.Size() - 1; i > 0; --i)
        {
            _astRecentFriendList[i] = _astRecentFriendList[i - 1];
        }
        _astRecentFriendList[0] = uiGID;
    }

public:
    //好友系统
    CTArray<unsigned int, FRIEND_MAX_FRIEND_COUNT> _astFriendList;          //好友列表
    CTArray<unsigned int, FRIEND_MAX_FRIEND_COUNT> _astTwoSideFriendList;   //双向好友列表
    CTArray<unsigned int, FRIEND_MAX_BLACK_COUNT> _astBlackFriendList;      //黑名单列表
    CTArray<unsigned int, FRIEND_MAX_RECENT_COUNT> _astRecentFriendList;    //最近联系
    CTArray<unsigned int, FRIEND_MAX_ENEMY_COUNT> _astEnemyFriendList;      //敌视列表
};

BEGIN_CODE_CONVERT(CPlayerFriendData)
CODE_CONVERT(_astFriendList)
CODE_CONVERT(_astTwoSideFriendList)
CODE_CONVERT(_astBlackFriendList)
CODE_CONVERT(_astRecentFriendList)
CODE_CONVERT(_astEnemyFriendList)
END_CODE_CONVERT(CPlayerFriendData)

class CFriendTreeDetailData : public CTCodeObject
{
public:
    CFriendTreeDetailData()
    {
        _ucHasPicked = 0;
        _iNowFruitCount = 0;
    }

    int _iNowFruitCount;        //当前果实数
    unsigned char _ucHasPicked; //是否已经采摘
};
BEGIN_CODE_CONVERT(CFriendTreeDetailData)
CODE_CONVERT(_iNowFruitCount)
CODE_CONVERT(_ucHasPicked)
END_CODE_CONVERT(CFriendTreeDetailData)


class CFriendTreeData : public CTCodeObject
{
public:
    CFriendTreeData()
    {
        stCanSendInviteCount.SetDefault(FRIEND_MAX_TREE_CAN_SEND_INVITE_COUNT);
        stCanSendBlessCount.SetDefault(FRIEND_MAX_TREE_CAN_SEND_BLESS_COUNT);
    }

    int AddFruit(int iIndex, int iCount)
    {
        if (iIndex < 0 || iIndex >= _astFriendTreeDatas.GetCount())
        {
            return RET_SYS_ERROR;
        }

        while (iIndex >= _astFriendTreeDatas.Size())
        {
            _astFriendTreeDatas.AddOneItem(CFriendTreeDetailData());
        }

        if (_astFriendTreeDatas[iIndex]._ucHasPicked == 0)
        {
            _astFriendTreeDatas[iIndex]._iNowFruitCount += iCount;
        }

        return 0;
    }

    int GetFruitCount(int iIndex)
    {
        if (iIndex < 0 
            || iIndex >= _astFriendTreeDatas.Size())
        {
            return 0;
        }

        return _astFriendTreeDatas[iIndex]._ucHasPicked == 0 ? _astFriendTreeDatas[iIndex]._iNowFruitCount : 0;
    }

    bool HasPick(int iIndex)
    {
        if (iIndex < 0 || iIndex >= _astFriendTreeDatas.GetCount())
        {
            return true;
        }

        if (iIndex >= _astFriendTreeDatas.Size())
        {
            return false;
        }

        return _astFriendTreeDatas[iIndex]._ucHasPicked == 1;
    }

    int PickFruit(int iIndex, int& iCount)
    {
        if (iIndex < 0 || iIndex >= _astFriendTreeDatas.GetCount())
        {
            return RET_SYS_ERROR;
        }

        while (iIndex >= _astFriendTreeDatas.Size())
        {
            _astFriendTreeDatas.AddOneItem(CFriendTreeDetailData());
        }

        iCount = _astFriendTreeDatas[iIndex]._iNowFruitCount;
        _astFriendTreeDatas[iIndex]._ucHasPicked = 1;
        return 0;
    }

    CDailyReflushChar stCanSendInviteCount;     //还可发送邀请的次数
    CDailyReflushChar stCanSendBlessCount;      //还可发送的祝福次数
    CTLib::CTArray<CFriendTreeDetailData, FRIEND_MAX_TREE_CONFIG_COUNT> _astFriendTreeDatas;
};

BEGIN_CODE_CONVERT(CFriendTreeData)
CODE_CONVERT(stCanSendInviteCount)
CODE_CONVERT(stCanSendBlessCount)
CODE_CONVERT(_astFriendTreeDatas)
END_CODE_CONVERT(CFriendTreeData)

class CRoleTitle : public CTCodeObject
{
public:
    CRoleTitle ()
    {
        _ucTitle = 0;
        _iExpiredTime = 0;
    }

    unsigned char _ucTitle;
    int _iExpiredTime;
};
BEGIN_CODE_CONVERT(CRoleTitle)
CODE_CONVERT(_ucTitle)
CODE_CONVERT(_iExpiredTime)
END_CODE_CONVERT(CRoleTitle)

class CRoleTitleData : public CTCodeObject
{
public:
    CRoleTitleData ()
    {
        _astTitles.Clear();
        _iLoginNotifyTime = 0;
    }

    int AddNewTitle (CRoleTitle & stNewTitle)
    {
        for (int i = 0; i < _astTitles.Size(); i++)
        {
            if (_astTitles[i]._ucTitle == stNewTitle._ucTitle)
            {
                _astTitles[i] = stNewTitle;
                return 0;
            }
        }

        if (_astTitles.Size() > MAX_ROLE_TITLE_CNT)
        {
            return ERROR_ROLE_TITLE_REACH_MAX;
        }

        _astTitles.AddOneItem(stNewTitle);
        return 0;
    }

    void DelExpiredTitle (int iNowTime)
    {
        for (int i = 0; i < _astTitles.Size(); )
        {
            if (_astTitles[i]._iExpiredTime < iNowTime)
            {
                _astTitles.DelOneItem(i);
            }
            else
            {
                ++i;
            }
        }
    }

    bool HasTitle (EN_ROLE_TITLE_TYPE enTitle, int iNowTime)
    {
        for (int i = 0; i < _astTitles.Size(); ++i)
        {
            if (_astTitles[i]._ucTitle == enTitle)
            {
                if (_astTitles[i]._iExpiredTime > iNowTime)
                {
                    return true;
                }

                break;
            }
        }

        return false;
    }

    CTArray<CRoleTitle, MAX_ROLE_TITLE_CNT> _astTitles;
    int _iLoginNotifyTime;   //上次登录时发送跑马灯的时间
};
BEGIN_CODE_CONVERT(CRoleTitleData)
CODE_CONVERT(_astTitles)
CODE_CONVERT(_iLoginNotifyTime);
END_CODE_CONVERT(CRoleTitleData)


//别人可以查看的数据(可被单独查询，但是不能单独更新)
class CPlayerSnsCommInfo : public CTCodeObject
{
public:
    CPlayerSnsCommInfo()
    {
        Clear();
    }

    void Clear()
    {
        _uiGID = 0;
        _sRoleName.Set("");
        _ucAcademy = ACADEMY_TYPE_NONE;
        _usLevel = 1;
        _i64NowExp = 0;

        _iLevChgTime = 0;
        _iRepuChgTime = 0;

        _ucIsMale = 0;
        _ucCareer = 0;

        _iArenaRank = 0;
        _iReputation = 0;
        _iRoleFighting = 0;
        _iTeamFighting = 0;

         _uiClanId = 0;
        _iContribution = 0;

        _iLastLogInTime = 0;
        _iLastLogOutTime = 0;

        _ucHasGoblin = 0;
        _iGoblinAppearTime = 0;
        _ucIsInited = 0;

        _stCanSendBlessCount.SetDefault(FRIEND_MAX_TREE_CAN_SEND_BLESS_COUNT);
    }

    //获取离线时间(单位: 秒)
    int GetOffLineTime (int iNow)
    {
        if (_iLastLogInTime >= _iLastLogOutTime)
        {
            return 0;
        }

        return iNow - _iLastLogOutTime;
    }

    unsigned char               _ucIsInited;
    unsigned int _uiGID;
    CTSizeString<ROLENAME_LEN>  _sRoleName;

    unsigned char               _ucAcademy;
    unsigned short              _usLevel;
    int64                       _i64NowExp;

    int                        _iLevChgTime;
    int                        _iRepuChgTime;

    int                        _iReputation;

    unsigned char               _ucIsMale;
    unsigned char               _ucCareer;
    int                         _iArenaRank;
    int                         _iTeamFighting;
    int                         _iRoleFighting;

    unsigned int                _uiClanId;        //玩家所在家族ID
    int                         _iContribution;  //家族贡献度(显示成员信息时使用,退出家族后不重置为0)

    int                         _iLastLogInTime;  //用户登入时间 (计算家族成员累计离线时间时使用)
    int                         _iLastLogOutTime; //用户登出时间 (计算家族成员累计离线时间时使用)

    //花园数据
    unsigned char _ucHasGoblin;         //是否有地精
    int           _iGoblinAppearTime;   //地精出现时间

    //
    CTSizeString<USER_TOKEN_LEN>  _sUserToken;

    CRoleTitleData  _stTitle;  //玩家称号

    //好友经验树数据
    CDailyReflushChar _stCanSendBlessCount;      //还可发送的祝福次数
};
BEGIN_CODE_CONVERT(CPlayerSnsCommInfo)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_sRoleName)
CODE_CONVERT(_ucAcademy)
CODE_CONVERT(_usLevel)
CODE_CONVERT(_ucIsMale)
CODE_CONVERT(_ucCareer)
CODE_CONVERT(_iArenaRank)

CODE_CONVERT(_uiClanId)
CODE_CONVERT(_iContribution)

CODE_CONVERT(_iLastLogInTime)
CODE_CONVERT(_iLastLogOutTime)

CODE_CONVERT(_ucHasGoblin)
CODE_CONVERT(_iGoblinAppearTime)

CODE_CONVERT(_sUserToken)

CODE_CONVERT(_i64NowExp)
CODE_CONVERT(_iReputation)
CODE_CONVERT(_iTeamFighting)
CODE_CONVERT(_iRoleFighting)

CODE_CONVERT(_ucIsInited)
CODE_CONVERT(_stTitle)

CODE_CONVERT(_stCanSendBlessCount)
CODE_CONVERT(_iLevChgTime)
CODE_CONVERT(_iRepuChgTime)
END_CODE_CONVERT(CPlayerSnsCommInfo)

//用户统计数据
class CPlayerStatic : public CTCodeObject
{
public:
    CPlayerStatic()
    {
        _stTodayRoleGetExp.SetDefault(0);
        _stTodayGetReputation.SetDefault(0);
        _stTodayGetSilver.SetDefault(0);
        _stTodayContribution.SetDefault(0);

        _iMaxEquipStrengthLevel = 0;
    }

public:
    CDailyReflushInt _stTodayRoleGetExp;     //今日主角获得的经验
    CDailyReflushInt _stTodayGetReputation;  //今日获得的声望
    CDailyReflushInt64 _stTodayGetSilver;    //今日获得的银币
    CDailyReflushInt  _stTodayContribution;  //今日提供的贡献度

    int _iMaxEquipStrengthLevel;             //最高强化等级
};
BEGIN_CODE_CONVERT(CPlayerStatic)
CODE_CONVERT(_stTodayRoleGetExp)
CODE_CONVERT(_stTodayGetReputation)
CODE_CONVERT(_stTodayGetSilver)
CODE_CONVERT(_stTodayContribution)
CODE_CONVERT(_iMaxEquipStrengthLevel)
END_CODE_CONVERT(CPlayerStatic)

//用于OSS的保存在用户身上的数据
class CPlayerOssInfo : public CTCodeObject
{
public:
    CPlayerOssInfo()
    {
        _ucHasPaied = 0;
        _usLevel = 0;
        _iFirstPayTime = 0;
        _iRegTime = 0;
        _iLastLoginTime = 0;
        _iLastActTime = 0;
        _iTodayLoginSec = 0;
        _iFirstPayFee = 0;
    }

public:
    unsigned char _ucHasPaied;      //是否已经付费
    unsigned short _usLevel;        //等级信息
    int         _iFirstPayFee;      //首次付费金额
    int         _iFirstPayTime;     //首次支付时间
    int         _iRegTime;          //帐号注册时间
    int         _iLastLoginTime;    //上次登录时间
    int         _iLastActTime;      //上次活跃时间
    int         _iTodayLoginSec;    //今天累计登录时间
};
BEGIN_CODE_CONVERT(CPlayerOssInfo)
CODE_CONVERT(_ucHasPaied)
CODE_CONVERT(_iFirstPayFee)
CODE_CONVERT(_usLevel)
CODE_CONVERT(_iFirstPayTime)
CODE_CONVERT(_iRegTime)
CODE_CONVERT(_iLastLoginTime)
CODE_CONVERT(_iLastActTime)
CODE_CONVERT(_iTodayLoginSec)
END_CODE_CONVERT(CPlayerOssInfo)

//用于更新OSS数据的结构
class CPlayerOssData : public CTCodeObject
{
public:
    CPlayerOssData()
    {
        _iUpdateTime = 0;
        _uiGID = 0;
        _ucHasPaied = 0;
        _usNowLevel = 0;
        _iFirstPayTime = 0;
        _iRegTime = 0;
        _iLoginTime = 0;
        _iActTime = 0;
        _iTodayLoginSec = 0;
        _iFirstPayFee = 0;
    }

public:
    int         _iUpdateTime;       //统计时间
    unsigned int _uiGID;
    unsigned char _ucHasPaied;      //是否已经付费
    unsigned short _usNowLevel;     //当前等级
    int          _iFirstPayTime;   //首次支付时间
    int          _iFirstPayFee;    //首次支付金额
    int          _iRegTime;         //帐号注册时间
    int         _iLoginTime;        //本次登录时间
    int         _iActTime;          //本次开始活跃时间
    int         _iTodayLoginSec;    //今日累计登录秒数
};
BEGIN_CODE_CONVERT(CPlayerOssData)
CODE_CONVERT(_iUpdateTime)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_ucHasPaied)
CODE_CONVERT(_usNowLevel)
CODE_CONVERT(_iFirstPayTime)
CODE_CONVERT(_iRegTime)
CODE_CONVERT(_iLoginTime)
CODE_CONVERT(_iActTime)
CODE_CONVERT(_iTodayLoginSec)
CODE_CONVERT(_iFirstPayFee)
END_CODE_CONVERT(CPlayerOssData)

//金币\银币操作
enum EN_OSS_MONEY_OPT
{
    OSS_MONEY_ADD_GOLD = 1,
    OSS_MONEY_SUB_GOLD = 2,
    OSS_MONEY_FIRST_BUY = 3,    //首次购买物品统计
    OSS_MONEY_BUY_GOODS = 4,    //出售物品统计
    OSS_MONEY_INNER_BUY = 5,    //游戏内购买物品
};

//金币\银币操作模块
enum EN_OSS_MONEY_MODULE
{
    OSS_MONEY_MODULE_01 = 1, //购买精力

    OSS_MONEY_MODULE_02 = 2, //清除上课CD时间
    OSS_MONEY_MODULE_03 = 3, //购买必修课次数
    OSS_MONEY_MODULE_04 = 4, //购买选修课次数

    OSS_MONEY_MODULE_05 = 5, //深层开采魔晶

    OSS_MONEY_MODULE_06 = 6, //装备合成

    OSS_MONEY_MODULE_07 = 7, //花园购买土地
    OSS_MONEY_MODULE_08 = 8, //花园加速成长
    OSS_MONEY_MODULE_09 = 9, //花园购买锄头
    OSS_MONEY_MODULE_10 = 10, //花园购买种子

    OSS_MONEY_MODULE_11 = 11, //商店购买物品
    OSS_MONEY_MODULE_18 = 18, //神秘商店金币刷新物品

    OSS_MONEY_MODULE_12 = 12, //购买背包仓库格子
    OSS_MONEY_MODULE_23 = 23, //清除宠物果实CD时间

    OSS_MONEY_MODULE_13 = 13, //购买博物馆扫荡次数
    OSS_MONEY_MODULE_14 = 14, //重置精英副本攻打次数
    OSS_MONEY_MODULE_15 = 15, //秘境重置

    OSS_MONEY_MODULE_16 = 16, //大喇叭

    OSS_MONEY_MODULE_17 = 17, //创建家族
    OSS_MONEY_MODULE_19 = 19, //家族捐献

    OSS_MONEY_MODULE_20 = 20, //宠物培养1
    OSS_MONEY_MODULE_29 = 29, //宠物培养2
    OSS_MONEY_MODULE_31 = 31, //清除宠物CD时间

    OSS_MONEY_MODULE_21 = 21, //购买竞技次数
    OSS_MONEY_MODULE_22 = 22, //消除战斗冷却

    OSS_MONEY_MODULE_24 = 24, //家族捐献

    OSS_MONEY_MODULE_25 = 25, //魔药炼药
    OSS_MONEY_MODULE_26 = 26, //魔药提纯
    OSS_MONEY_MODULE_27 = 27, //魔药转移

    OSS_MONEY_MODULE_28 = 28, //竞拍

    OSS_MONEY_MODULE_30 = 30, //购买小秘书

    OSS_MONEY_MODULE_32 = 32, //世界BOOS梅林的祝福
    OSS_MONEY_MODULE_33 = 33, //世界BOOS复活

    OSS_MONEY_MODULE_34 = 34, //怪物攻城战消耗

    OSS_MONEY_MODULE_35 = 35, //wish

    OSS_MONEY_MODULE_36 = 36, //家族神树浇水
    OSS_MONEY_MODULE_37 = 37, //家族闯关

    OSS_MONEY_MODULE_38 = 38, //装备转换

    OSS_MONEY_MODULE_39 = 39, //金币占卜

    OSS_MONEY_MODULE_40 = 40, //日常任务找回

    OSS_MONEY_MODULE_41 = 41, //暗拍

    OSS_MONEY_MODULE_42 = 42, //炼金

    OSS_MONEY_MODULE_43 = 43, //金字塔重置

    OSS_MONEY_MODULE_44 = 44, //每日签到活动中补签
    OSS_MONEY_MODULE_45 = 45, //宝箱争夺

    OSS_MONEY_MODULE_46 = 46, //装备洗练和祝福

    OSS_MONEY_MODULE_47 = 47, //解锁坐骑位

    OSS_MONEY_MODULE_48 = 48, //坐骑猎魂

    OSS_MONEY_MODULE_49 = 49, //魔晶潜能

    OSS_MONEY_MODULE_50 = 50, //激活新的宠物形态

    OSS_MONEY_MODULE_51 = 51, //普通商店购买物品

    OSS_MONEY_MODULE_52 = 52, //开服特卖

    OSS_MONEY_MODULE_53 = 53, //家族招募

    OSS_MONEY_MODULE_54 = 54, //时装续期

    OSS_MONEY_MODULE_55 = 55, //领地战复活

    OSS_MONEY_MODULE_56 = 56, //奖励找回

    OSS_MONEY_MODULE_57 = 57, //转盘
    OSS_MONEY_MODULE_58 = 58, //摇摇乐
    OSS_MONEY_MODULE_59 = 59, //回购列表购买道具
};

//OSS模块
enum EN_OSS_MODULE
{
    OSS_MODULE_VIP              = 1, //VIP充值
    OSS_MODULE_MONSTER          = 2, //打怪物
    OSS_MODULE_INSTANCE         = 3, //打副本
    OSS_MODULE_WISH             = 4, //许愿池
    OSS_MODULE_GM               = 5, //GM命令
    OSS_MODULE_ACADEMY          = 6, //选择学院
    OSS_MODULE_AUCTION          = 7, //拍卖会
    OSS_MODULE_ADMBOSS          = 8, //学院BOSS
    OSS_MODULE_SPDACT           = 9, //精彩活动
    OSS_MODULE_ARENA            = 10, //竞技场
    OSS_MODULE_ITEM_PRODUCE     = 11, //物品产出
    OSS_MODULE_TREE             = 12, //家族神树
    OSS_MODULE_ENMCITY          = 13, //怪物攻城
    OSS_MODULE_DAYTASK          = 14, //每日任务
    OSS_MODULE_DICE             = 15, //家族DICE
    OSS_MODULE_LESSON           = 16, //上课
    OSS_MODULE_DOOR             = 17, //魔界门
    OSS_MODULE_ALCHEMY          = 18, //炼金
    OSS_MODULE_GARDEN           = 19, //花园
    OSS_MODULE_MUSE             = 20, //冥想
    OSS_MODULE_PET              = 21, //宠物
    OSS_MODULE_WLDBOSS          = 22, //世界BOSS
    OSS_MODULE_TASK             = 23, //任务
    OSS_MODULE_GIFT             = 24, //礼包
    OSS_MODULE_CLANBAT          = 25, //家族战
    OSS_MODULE_ITEM_CONSUME     = 26, //物品消耗
    OSS_MODULE_QQ_PAY           = 27, //QQ支付
    OSS_MODULE_ROLE_LOGIN       = 28, //角色登录
    OSS_MODULE_CREATE_ROLE      = 29, //创建角色
    OSS_MODULE_PYRAMID          = 30, //金字塔
    OSS_MODULE_CLAN_DIAL        = 31, //家族转盘
    OSS_MODULE_LOGIN_GOLD       = 32, //登陆送符石
    OSS_MODULE_GROW_FUND        = 33, //成长基金
    OSS_MODULE_PAY_BACK         = 34, //消费返利
    OSS_MODULE_NEWBIE_TASK      = 35, //新手任务
    OSS_MODULE_FIGHT_FOR_BOX    = 36, //宝箱争夺
    OSS_MODULE_QQ_FRIEND_DIAL   = 37, //QQ好友邀请转盘
    OSS_MODULE_DRUG_INHERIT     = 38, //魔药传承
    OSS_MODULE_MALL_OWN         = 39, //商城
    OSS_MODULE_NEWSALES         = 40, //开服特卖
    OSS_MODULE_FIGHT_END        = 41, //一战到底奖励
    OSS_MODULE_ACA_CUP          = 42, //学院杯
    OSS_MODULE_MARKET           = 43, //任务集市
    OSS_MODULE_EGG              = 44, //砸蛋
    OSS_MODULE_32WAN_ADD_GOLD   = 45, //32玩充值
    OSS_MODULE_MANOR_BATTLE     = 46, //领地战
    OSS_MODULE_REWARD_BACK      = 47, //奖励找回
    OSS_MODULE_LOGIN_REWARD     = 48, //登录奖励
    OSS_MODULE_LUCKY_DIAL       = 49, //幸运转盘
    OSS_MODULE_DAY_WISH         = 50, //每日许愿
    OSS_MODULE_DAY_SIGN         = 51, //每日签到
    OSS_MODULE_RED_PACKET       = 52, //领红包活动
};

//OSS模块 物品操作
enum EN_OSS_ITEM
{
    OSS_ITEM_DROP               =  1, //物品掉落
    OSS_ITEM_DISCARD            =  2, //丢弃物品
    OSS_ITEM_SHOP_BUY           =  3, //商店购买
    OSS_ITEM_SELL_LIST          =  4, //回购列表
    OSS_ITEM_COMBINE_CARD       =  5, //卡片合成
    OSS_ITEM_MERGE_CARD         =  6, //卡片一键合成
    OSS_ITEM_COLLECT_CARD       =  7, //收取卡片
    OSS_ITEM_EXCHANGE_CARD      =  8, //兑换卡片
    OSS_ITEM_MAKE_EQUIP         =  9, //装备合成
    OSS_ITEM_PICK_UP            = 10, //拾捡物品
    OSS_ITEM_TRANSFORM_EQUIP    = 11, //装备转换
};

//更新用户金币\银币使用的结构
class CPlayerOssMoney : public CTCodeObject
{
public:
    CPlayerOssMoney()
    {
        _iUpdateTime = 0;
        _uiGID = 0;
        _ucOpt = 0;
        _usModule = 0;
        _iAmount = 0;
    }

public:
    int            _iUpdateTime;  //统计时间
    unsigned int   _uiGID;
    unsigned char  _ucOpt;        // EN_OSS_MONEY_OPT
    unsigned short _usModule;     // 产出模块
    int            _iAmount;
};
BEGIN_CODE_CONVERT(CPlayerOssMoney)
CODE_CONVERT(_iUpdateTime)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_ucOpt)
CODE_CONVERT(_usModule)
CODE_CONVERT(_iAmount)
END_CODE_CONVERT(CPlayerOssMoney)


class COssZoneData : public CTCodeObject
{
public:
    COssZoneData()
    {
        _iUpdateTime = 0;
        _uiZoneID = 0;
        _iNowOnline = 0;
        _iQuarterRegister = 0;
        _uiQuarterIncome = 0;
    }

public:
    int         _iUpdateTime;       //统计时间
    unsigned int         _uiZoneID;
    int         _iNowOnline;
    int         _iQuarterRegister;  //15分钟注册
    unsigned int _uiQuarterIncome;  //15分钟充值(金币)
};
BEGIN_CODE_CONVERT(COssZoneData)
CODE_CONVERT(_iUpdateTime)
CODE_CONVERT(_uiZoneID)
CODE_CONVERT(_iNowOnline)
CODE_CONVERT(_iQuarterRegister)
CODE_CONVERT(_uiQuarterIncome)
END_CODE_CONVERT(COssZoneData)

class COssZoneInfo : public CTCodeObject
{
public:
    COssZoneInfo()
    {
        _iQuarterRegister = 0;
    }

public:
    int _iQuarterRegister; //15分钟注册
};
BEGIN_CODE_CONVERT(COssZoneInfo)
CODE_CONVERT(_iQuarterRegister)
END_CODE_CONVERT(COssZoneInfo)

//用户指引数据(前台用)
class CUserGuideData : public CTCodeObject
{
public:

    CUserGuideData()
    {
    }

public:
    CTLib::CTSizeString<100> _szInfo;
};
BEGIN_CODE_CONVERT(CUserGuideData)
CODE_CONVERT(_szInfo)
END_CODE_CONVERT(CUserGuideData)

//只有自己登录需要访问的数据
class CPlayerSnsMyInfo : public CTCodeObject
{
public:
    CPlayerSnsMyInfo()
    {
        Clear();
    }

    void Clear()
    {
        _uiGID = 0;

        _stFriendData.Clear();
    }

    unsigned int _uiGID;

    //好友系统
    CPlayerFriendData   _stFriendData;

    //花园系统
    CUesrGardenData     _stGardenData;

    //用户数据统计
    CPlayerStatic       _stPlayerStatic;

    //OSS用数据
    CPlayerOssInfo      _stPlayerOssInfo;

    //离线消息
    COfflineTips        _stOfflineTips;

    //离线物品
    COfflineItems       _stOfflineItems;

    //用户指引数据(前台用)
    CUserGuideData      _stUserGuideData;

    //好友经验树
    CFriendTreeData     _stFriendTreeData;

};
BEGIN_CODE_CONVERT(CPlayerSnsMyInfo)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_stFriendData)
CODE_CONVERT(_stGardenData)
CODE_CONVERT(_stPlayerStatic)
CODE_CONVERT(_stPlayerOssInfo)
CODE_CONVERT(_stOfflineTips)
CODE_CONVERT(_stOfflineItems)
CODE_CONVERT(_stUserGuideData)
CODE_CONVERT(_stFriendTreeData)
END_CODE_CONVERT(CPlayerSnsMyInfo)

//用户社交相关数据:只有我访问的数据
class CPlayerSnsDetailInfo : public CTCodeObject
{
public:
    CPlayerSnsDetailInfo()
    {
        _uiGID = 0;

        _stMyInfo.Clear();
        _stCommInfo.Clear();
    }

    unsigned int _uiGID;

    CPlayerSnsMyInfo _stMyInfo;
    CPlayerSnsCommInfo _stCommInfo;
};

BEGIN_CODE_CONVERT(CPlayerSnsDetailInfo)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_stMyInfo)
CODE_CONVERT(_stCommInfo)
END_CODE_CONVERT(CPlayerSnsDetailInfo)

//////////////////////////////////////////////////////////////////////////
class CArenaHeroData : public CTCodeObject
{
public:
    CArenaHeroData()
    {
        _uiGID = 0;
        _cTend = 0;
    }

    virtual ~CArenaHeroData()
    {
    }

public:
    unsigned int _uiGID;
    char _cTend;  // 小于0是下降
};
BEGIN_CODE_CONVERT(CArenaHeroData)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_cTend)
END_CODE_CONVERT(CArenaHeroData)

class CArenaHeroList : public CTCodeObject
{
public:
    CArenaHeroList()
    {
        Clear();
    }

    void Clear()
    {
        _astHeroData.Clear();
    }

    int UpdateList(CArenaHeroList& stNewList)
    {
        if (_astHeroData.Size() == 0)
        {
            _astHeroData = stNewList._astHeroData;
            return 0;
        }

        for (int i = 0; i < stNewList._astHeroData.Size(); ++i)
        {
            CArenaHeroData& stNewHeroData = stNewList._astHeroData[i];
            stNewHeroData._cTend = 20;

            for (int j = 0; j < _astHeroData.Size(); ++j)
            {
                CArenaHeroData& stOldHeroData = _astHeroData[j];
                if (stOldHeroData._uiGID == stNewHeroData._uiGID)
                {
                    stNewHeroData._cTend = j - i;
                    break;
                }
            }
        }

        _astHeroData = stNewList._astHeroData;
        return 0;
    }

public:
    CTLib::CTArray<CArenaHeroData, ARENA_MAX_HERO_LIST_COUNT> _astHeroData;
};
BEGIN_CODE_CONVERT(CArenaHeroList)
CODE_CONVERT(_astHeroData)
END_CODE_CONVERT(CArenaHeroList)

class CUnactPartnerInfo : public CTCodeObject
{
public:
    CUnactPartnerInfo()
    {
        Clear();
    }

    void Clear()
    {
        _uiGID = 0;
        _astListData.Clear();
    }

    bool IsFullListData()
    {
        return _astListData.Size() >= MAX_PARTNER_CFG_COUNT;
    }

    int DelListData(short shResID)
    {
        for (int i = 0; i < _astListData.Size(); )
        {
            if (shResID == _astListData[i]._shResID)
            {
                int iRet = _astListData.DelOneItem(i);
                if (iRet < 0)
                {
                    return iRet;
                }
            }
            else
            {
                ++i;
            }
        }

        return 0;
    }

    int FindListData(short shResID)
    {
        for (int i = 0; i < _astListData.Size(); ++i)
        {
            if (shResID == _astListData[i]._shResID)
            {
                return i;
            }
        }

        return -1;
    }

    CPartnerListData& GetPartnerListData(int iIndex) {return _astListData[iIndex];}

public:
    unsigned int _uiGID;
    CTArray<CPartnerListData, MAX_PARTNER_CFG_COUNT> _astListData;
};

BEGIN_CODE_CONVERT(CUnactPartnerInfo)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_astListData)
END_CODE_CONVERT(CUnactPartnerInfo)

//////////////////////////////////////////////////////////////////////////

//竞技场全局数据
class CArenaZoneData : public CTCodeObject
{
public:
    CArenaZoneData()
    {
        _iLastAccountTime = 0;
        _iNextAccountTime = 0;
        _iLastWorldBossLevel = 0;
    }

public:
    int _iLastAccountTime;                                      //上次结算时间
    int _iNextAccountTime;                                      //下次结算时间
    CArenaHeroList _stHeroList;
    CTLib::CTArray<CBattleTitle, ARENA_MAX_TOP_INFO_COUNT> _astTopTitle;       //置顶信息
    int _iLastWorldBossLevel;                                   //上次的世界boss等级
};
BEGIN_CODE_CONVERT(CArenaZoneData)
CODE_CONVERT(_iLastAccountTime)
CODE_CONVERT(_iNextAccountTime)
CODE_CONVERT(_stHeroList)
CODE_CONVERT(_astTopTitle)
CODE_CONVERT(_iLastWorldBossLevel)
END_CODE_CONVERT(CArenaZoneData)

class CShopHistoryItemData : public CTCodeObject
{
public:
    CShopHistoryItemData()
    {
        _uiGid = 0;
        _ucItemType = 0;
        _usItemId = 0;
    }

    unsigned int _uiGid;
    unsigned char  _ucItemType;
    unsigned short _usItemId;
};
BEGIN_CODE_CONVERT(CShopHistoryItemData)
CODE_CONVERT(_uiGid)
CODE_CONVERT(_ucItemType)
CODE_CONVERT(_usItemId)
END_CODE_CONVERT(CShopHistoryItemData)

//商店全区数据
class CShopZoneData : public CTCodeObject
{
public:
    CShopZoneData ()
    {
        _astShopHistory.Clear();
    }

    void AddHistoryItem(CShopHistoryItemData & stItemData)
    {
        if (_astShopHistory.Size() == MAX_MYSTICAL_SHOP_HISTORY_NUM)
        {
            _astShopHistory.ShiftDelOneItem(0);
        }

        _astShopHistory.AddOneItem(stItemData);
    }

    CTArray<CShopHistoryItemData, MAX_MYSTICAL_SHOP_HISTORY_NUM> _astShopHistory; //神秘商店购买记录
};
BEGIN_CODE_CONVERT(CShopZoneData)
CODE_CONVERT(_astShopHistory)
END_CODE_CONVERT(CShopZoneData)

//学院排名数据
class CAcademyRankData : public CTCodeObject
{
public:
    CAcademyRankData()
    {

    }

    void Clear()
    {
        _uiGID = 0;
        _iData = 0;
    }

    unsigned int _uiGID;
    int _iData;
};
BEGIN_CODE_CONVERT(CAcademyRankData)
CODE_CONVERT(_uiGID)
CODE_CONVERT(_iData)
END_CODE_CONVERT(CAcademyRankData)

class CAcademyRankDatas : public CTCodeObject
{
public:
    CAcademyRankDatas()
    {
        Clear();
    }

    void Clear()
    {
        _astRepRank.Clear();
        _astSilverRank.Clear();
        _astArenaRank.Clear();
        _astConRank.Clear();
    }

    CTLib::CTArray<CAcademyRankData, MAX_ACADEMY_RANK_COUNT> _astRepRank;
    CTLib::CTArray<CAcademyRankData, MAX_ACADEMY_RANK_COUNT> _astSilverRank;
    CTLib::CTArray<CAcademyRankData, MAX_ACADEMY_RANK_COUNT> _astArenaRank;
    CTLib::CTArray<CAcademyRankData, MAX_ACADEMY_RANK_COUNT> _astConRank;
};
BEGIN_CODE_CONVERT(CAcademyRankDatas)
CODE_CONVERT(_astRepRank)
CODE_CONVERT(_astSilverRank)
CODE_CONVERT(_astArenaRank)
CODE_CONVERT(_astConRank)
END_CODE_CONVERT(CAcademyRankDatas)

//学院数据
typedef CTLib::CTArray<CTLib::CTSizeString<ROLENAME_LEN>, MAX_ACADEMY_NEWLY_ENTER_ROLENAME_COUNT> T_NEWLY_ENTER_ACA_ROLENAME_LIST;
class CAcademyZoneData : public CTCodeObject
{
public:
    CAcademyZoneData()
    {
        Clear();
    }

    void Clear()
    {
        _iLastRankUpdateTime = 0;

        ClearRank();

        _astNewlyEnterAcaRolenames.m_iUsedCount = _astNewlyEnterAcaRolenames.GetCount();
        for (int i = 0; i < _astNewlyEnterAcaRolenames.Size(); ++i)
        {
            _astNewlyEnterAcaRolenames[i].Clear();
        }
    }

    void ClearRank()
    {
        _astAllRanks.m_iUsedCount = _astAllRanks.GetCount();
        for (int i = 0; i < _astAllRanks.Size(); ++i)
        {
            _astAllRanks[i].Clear();
        }
    }

public:
    int _iLastRankUpdateTime;       //排行榜最后更新时间
    CTLib::CTArray<CAcademyRankDatas, ACADEMY_TYPE_COUNT + 1> _astAllRanks;

    CTLib::CTArray<T_NEWLY_ENTER_ACA_ROLENAME_LIST, ACADEMY_TYPE_COUNT + 1> _astNewlyEnterAcaRolenames; //新进入学院的玩家昵称
};
BEGIN_CODE_CONVERT(CAcademyZoneData)
CODE_CONVERT(_iLastRankUpdateTime)
CODE_CONVERT(_astAllRanks)
CODE_CONVERT(_astNewlyEnterAcaRolenames)
END_CODE_CONVERT(CAcademyZoneData)

//家族战奖励数据
class CClanBattleRankData : public CTCodeObject
{
public:
    CClanBattleRankData()
    {
        _uiID = 0;
        _iData = 0;
        _iData2 = 0;

        _ucHasGetBonus = 0;
        _ucAcademy = 0;
    }

    unsigned int _uiID;
    int _iData;
    int _iData2;

    unsigned char _ucHasGetBonus;   //是否领奖
    unsigned char _ucAcademy;

    CTSizeString<ROLENAME_LEN> _szRoleName;
    CTSizeString<CLAN_NAME_STRING_SIZE> _szClanName;
};

BEGIN_CODE_CONVERT(CClanBattleRankData)
CODE_CONVERT(_uiID)
CODE_CONVERT(_iData)
CODE_CONVERT(_iData2)
CODE_CONVERT(_ucHasGetBonus)
END_CODE_CONVERT(CClanBattleRankData)

class CClanBattleZoneData : public CTCodeObject
{
public:
    CClanBattleZoneData()
    {
        Clear();
    }

    void Clear()
    {
        _astRoleRankDatas.Clear();
        _astClanRankDatas.Clear();
    }

    CTLib::CTArray<CClanBattleRankData, CLAN_BATTLE_ROLE_RANK_COUNT> _astRoleRankDatas;
    CTLib::CTArray<CClanBattleRankData, CLAN_BATTLE_CLAN_RANK_COUNT> _astClanRankDatas;
};
BEGIN_CODE_CONVERT(CClanBattleZoneData)
CODE_CONVERT(_astRoleRankDatas)
CODE_CONVERT(_astClanRankDatas)
END_CODE_CONVERT(CClanBattleZoneData)

//怪物攻城战大区数据
class CEnemyAtkCityZoneData : public CTCodeObject
{
public:
    CEnemyAtkCityZoneData()
    {
        Clear();
    }

    void Clear()
    {
        _astAtkRank.m_iUsedCount = _astAtkRank.GetCount();

        for (int i = 0; i < _astAtkRank.Size(); ++i)
        {
            _astAtkRank[i] = 0;
        }
    }

    int GetRank(unsigned char ucAcaID)
    {
        for (int i = 0; i < _astAtkRank.Size(); ++i)
        {
            if (_astAtkRank[i] == ucAcaID)
            {
                return i + 1;
            }
        }

        return 0;
    }

public:
    int _iCanTakeBonusBeginTime;    //可领奖的战斗开始时间 (注：每次用户战斗都会记录一个战斗时间，只有在这个时间内才可以领奖)
    int _iCanTakeBonusEndTime;      //可领奖的战斗结束时间

    CTLib::CTArray<unsigned char, ACADEMY_TYPE_COUNT + 1> _astAtkRank; //学院伤害排名(数组元素是学院ID)，主要用来发奖励
};
BEGIN_CODE_CONVERT(CEnemyAtkCityZoneData)
CODE_CONVERT(_iCanTakeBonusBeginTime)
CODE_CONVERT(_iCanTakeBonusEndTime)
CODE_CONVERT(_astAtkRank)
END_CODE_CONVERT(CEnemyAtkCityZoneData)

//金秋猎奇活动
class CGoldCardAct : public CTCodeObject
{
public:
    unsigned int uiGID; 
    int  iGoldCardCount;  //获得的金色卡片数量
};

BEGIN_CODE_CONVERT(CGoldCardAct)
CODE_CONVERT(uiGID)
CODE_CONVERT(iGoldCardCount)
END_CODE_CONVERT(CGoldCardAct)

//学院杯大区数据
//决赛用户信息
class CAcaCupSecondRoleData : public CTCodeObject
{
public:
    CAcaCupSecondRoleData()
    {
        Clear();
    }

    void Clear()
    {
        _uiGID = 0;
        _ucAca = 0;
        _ucIsLoss = 0;
        _ucLossRound = 0;
        _ucHasInspire = 0;
        _ucHasBeenInspireCount = 0;
    }

    unsigned int _uiGID;
    unsigned char _ucAca;       //所属学院
    unsigned char _ucIsLoss;    //是否失败
    unsigned char _ucLossRound; //决赛第几轮被淘汰
    unsigned char _ucHasInspire; //是否已经鼓舞
    unsigned char _ucHasBeenInspireCount; //被鼓舞次数
};
BEGIN_CODE_CONVERT(CAcaCupSecondRoleData)
    CODE_CONVERT(_uiGID)
    CODE_CONVERT(_ucAca)
    CODE_CONVERT(_ucIsLoss)
    CODE_CONVERT(_ucLossRound)
    CODE_CONVERT(_ucHasInspire)
    CODE_CONVERT(_ucHasBeenInspireCount)
END_CODE_CONVERT(CAcaCupSecondRoleData)

class CAcaCupSecondRoundRecorder : public CTCodeObject //决赛战斗记录
{
public:
    CAcaCupSecondRoundRecorder()
    {
        _ucRound = 0;
        _uiGID_A = 0;
        _uiGID_B = 0;
        _bIsAWin = false;

    }

    unsigned char _ucSecondRound; //决赛轮数
    unsigned char _ucRound; //回合数
    unsigned int _uiGID_A;
    unsigned int _uiGID_B; 
    unsigned char _bIsAWin;          
    CTSizeString<MAX_VIDEO_KEY_LEN> _szVideo; //录像ID
};
BEGIN_CODE_CONVERT(CAcaCupSecondRoundRecorder)
    CODE_CONVERT(_ucSecondRound)
    CODE_CONVERT(_ucRound)
    CODE_CONVERT(_uiGID_A)
    CODE_CONVERT(_uiGID_B)
    CODE_CONVERT(_bIsAWin)
    CODE_CONVERT(_szVideo)
END_CODE_CONVERT(CAcaCupSecondRoundRecorder)

class CAcaCupZoneData : public CTCodeObject
{
public:
    CAcaCupZoneData()
    {
        _iNowSeq = 0;
        _ucNowStat = 0;
        _ucSecondRound = 0;
        _astSecondRole.m_iUsedCount = _astSecondRole.GetCount();
    }

    int           _iNowSeq;         //当前比赛的序列号
    unsigned char _ucNowStat;       //当前状态, 见ACA_CUP_STAT_TAG
    unsigned char _ucSecondRound;   //决赛第几轮
    CTArray<CAcaCupSecondRoleData, MAX_ACA_CAP_SECOND_ROLE_COUNT> _astSecondRole; //决赛者信息
    CTArray<CAcaCupSecondRoundRecorder, 150> _astAllVideos;     //所有录像
};
BEGIN_CODE_CONVERT(CAcaCupZoneData)
    CODE_CONVERT(_iNowSeq)
    CODE_CONVERT(_ucNowStat)
    CODE_CONVERT(_ucSecondRound)
    CODE_CONVERT(_astSecondRole)
    CODE_CONVERT(_astAllVideos)
END_CODE_CONVERT(CAcaCupZoneData)

class CManorBattleZoneData : public CTCodeObject
{
public:
    CManorBattleZoneData()
    {
        Clear();
    }

    void Clear()
    {
        _iBombLevel = 0;
        _uiClanID = 0;
    }

    virtual ~CManorBattleZoneData()
    {
    }

public:
    int _iBombLevel;
    unsigned int _uiClanID;
};
BEGIN_CODE_CONVERT(CManorBattleZoneData)
    CODE_CONVERT(_iBombLevel)
    CODE_CONVERT(_uiClanID)
END_CODE_CONVERT(CManorBattleZoneData)

class CRewardBackUnit : public CTCodeObject
{
public:
    CRewardBackUnit()
    {
        Clear();
    }

    void Clear()
    {
        _iDayZeroTime = 0;
        _iEnemyCityLvl = 0;
        _iEnemyCityTime = 0;
        _iAcademyBossLvl = 0;
        _iAcademyBossTime = 0;
        _iWorldBossLvlOne = 0;
        _iWorldBossLvlTwo = 0;
        _iWorldBossTimeOne = 0;
        _iWorldBossTimeTwo = 0;
    }

    virtual ~CRewardBackUnit()
    {
    }

    int GetDayZeroTime() const {return _iDayZeroTime;}

public:
    int _iDayZeroTime;
    int _iEnemyCityLvl;
    int _iEnemyCityTime;
    int _iAcademyBossLvl;
    int _iAcademyBossTime;
    int _iWorldBossLvlOne;
    int _iWorldBossLvlTwo;
    int _iWorldBossTimeOne;
    int _iWorldBossTimeTwo;
};
BEGIN_CODE_CONVERT(CRewardBackUnit)
    CODE_CONVERT(_iDayZeroTime)
    CODE_CONVERT(_iEnemyCityLvl)
    CODE_CONVERT(_iEnemyCityTime)
    CODE_CONVERT(_iAcademyBossLvl)
    CODE_CONVERT(_iAcademyBossTime)
    CODE_CONVERT(_iWorldBossLvlOne)
    CODE_CONVERT(_iWorldBossLvlTwo)
    CODE_CONVERT(_iWorldBossTimeOne)
    CODE_CONVERT(_iWorldBossTimeTwo)
END_CODE_CONVERT(CRewardBackUnit)

class CRewardBackZoneData : public CTCodeObject
{
public:
    CRewardBackZoneData()
    {
        Clear();
    }

    void Clear()
    {
        _astList.Clear();
    }

    virtual ~CRewardBackZoneData()
    {
    }

    int FindUnit(int iDayZeroTime)
    {
        for (int i = 0; i < _astList.Size(); ++i)
        {
            if (_astList[i].GetDayZeroTime() == iDayZeroTime)
            {
                return i;
            }
        }
        return -1;
    }

    CRewardBackUnit& GetUnit(int iIndex)
    {
        return _astList[iIndex];
    }

public:
    CTRankArray<CRewardBackUnit, MAX_REWARD_BACK_DAY_COUNT> _astList;
};
BEGIN_CODE_CONVERT(CRewardBackZoneData)
    CODE_CONVERT(_astList)
END_CODE_CONVERT(CRewardBackZoneData)

class CSDRecordUnit : public CTCodeObject
{
public:
    CSDRecordUnit()
    {
        Clear();
    }

    void Clear()
    {
        _ucItemType = 0;
        _usItemConfigID = 0;
        _iItemCount = 0;
        _iUpdateTime = 0;
        _uiGID = 0;
    }

    virtual ~CSDRecordUnit()
    {
    }

public:
    unsigned char   _ucItemType;
    unsigned short  _usItemConfigID;
    int             _iItemCount;
    int             _iUpdateTime;
    unsigned int    _uiGID;

};
BEGIN_CODE_CONVERT(CSDRecordUnit)
    CODE_CONVERT(_ucItemType)
    CODE_CONVERT(_usItemConfigID)
    CODE_CONVERT(_iItemCount)
    CODE_CONVERT(_iUpdateTime)
    CODE_CONVERT(_uiGID)
END_CODE_CONVERT(CSDRecordUnit)

class CSDChargeUnit : public CTCodeObject
{
public:
    CSDChargeUnit()
    {
        Clear();
    }

    void Clear()
    {
        _iGold = 0;
        _uiGID = 0;
    }

    virtual ~CSDChargeUnit()
    {
    }

public:
    int             _iGold;
    unsigned int    _uiGID;
};
BEGIN_CODE_CONVERT(CSDChargeUnit)
    CODE_CONVERT(_iGold)
    CODE_CONVERT(_uiGID)
END_CODE_CONVERT(CSDChargeUnit)

class CZoneData : public CTCodeObject
{
public:
    CZoneData()
    {
        _uiZoneID = 0;
        _iZoneOpenTime = 0;
        _iZoneCombineTime = 0;
        _iZoneRecorderCount = 1;
        _chStopOpenRegist = 0;
        _chStopCreateClan = 0;

        _iNowGID = 1;
        _iNowClanId = 1;

        _iTimeOffSet = 0;
        _iNeedCalcFruitTime = 0;
        _iClearTreeRankTime = 0;

        _stManorBattle.Clear();
        _stRewardBack.Clear();

        _ucSDGetBigBonus = 0;
        _astSDRecord.Clear();
        _astSDCharge.Clear();

        ClearGanEnData();

        _astRockRecord.Clear();
    }

    void ClearGanEnData()
    {
        _ucHasSendGanEnBigGift = 0;
        _iGanEnLastOpenTime = 0;
        _aui64GanEnRecorder.m_iUsedCount = _aui64GanEnRecorder.GetCount();
        for (int i = 0; i < _aui64GanEnRecorder.Size(); i++)
        {
            _aui64GanEnRecorder[i] = 0;
        }
	
        _aui64ZPRecorder.m_iUsedCount = _aui64ZPRecorder.GetCount();
	    for (int j = 0; j < _aui64ZPRecorder.Size(); j++)
        {
            _aui64ZPRecorder[j] = 0;
        }
    }

    static void TraceSize()
    {
        CT_TRACE(("CZoneData: %d", sizeof(CZoneData)));
        CT_TRACE(("CZoneData: %d", sizeof(CZoneData)));
    }

public:
    unsigned int _uiZoneID;     //大区ID(主键)

    int _iZoneOpenTime;         //大区开始时间
    int _iNowGID;               //当前分配的GID
    int _iNowClanId;            //未分配的起始家族ID
    int _iNowAuctionId;         //当前分配的拍卖会活动id
    int _iZoneCombineTime;      //合服时间
    int _iZoneRecorderCount;    //大区记录数
    char _chStopOpenRegist;     //停止开放注册标识
    char _chStopCreateClan;     //停止创建家族标识

    //竞技场数据
    CArenaZoneData _stArenaZoneData;

    //神秘商店
    CShopZoneData  _stShopZoneData;

    //副本数据
    CInstanceZoneData _stInstanceZoneData;

    //学院数据
    CAcademyZoneData _stAcaemyZoneData;

    //家族战数据
    CClanBattleZoneData _stClanBattleZoneData;

    //怪物攻城战
    CEnemyAtkCityZoneData _stEnemyAtkCityZoneData;

    //拍卖会
    CAuctionCommonData  _stAuctionZoneData;

    //OSS
    COssZoneInfo          _stOssZoneInfo;

    //时间修正值(测试用)
    int                   _iTimeOffSet;

    //下次计算摘果实次数和发放神树奖励的时间
    int                    _iNeedCalcFruitTime;

    //下次清空神树成长值排行榜的时间
    int                    _iClearTreeRankTime;

    //金秋猎奇活动排行榜
    CTRankArray<CGoldCardAct, MAX_SPLENDID_GOLD_CARD_MAX_RANK> _astGoldCardAct;

    //学院杯
    CAcaCupZoneData _stAcaCupZoneData;

    //精彩活动:感恩节砸蛋
    unsigned char _ucHasSendGanEnBigGift;
    CTArray<uint64, 3> _aui64GanEnRecorder;   //砸蛋记录
    CTArray<uint64, 10> _aui64ZPRecorder;     //转盘记录
    int _iGanEnLastOpenTime;    //砸蛋活动上次开启时间

    CManorBattleZoneData _stManorBattle; //领地战
    CRewardBackZoneData _stRewardBack; //奖励找回

    //精彩活动:双蛋活动
    unsigned char _ucSDGetBigBonus; //获得大奖的次数
    CTRankArray<CSDRecordUnit, MAX_SPLENDID_SD_RECORD_COUNT> _astSDRecord;
    CTRankArray<CSDChargeUnit, MAX_SPLENDID_SD_RANK_COUNT> _astSDCharge;
    CTRankArray<CSDRecordUnit, MAX_SPLENDID_ROCK_RECORD_COUNT> _astRockRecord;
};
BEGIN_CODE_CONVERT(CZoneData)
CODE_CONVERT(_uiZoneID)
CODE_CONVERT(_iZoneOpenTime)
CODE_CONVERT(_iNowGID)
CODE_CONVERT(_iNowClanId)
CODE_CONVERT(_stArenaZoneData)
CODE_CONVERT(_stShopZoneData)
CODE_CONVERT(_stInstanceZoneData)
CODE_CONVERT(_stAcaemyZoneData)
CODE_CONVERT(_stClanBattleZoneData)
CODE_CONVERT(_stEnemyAtkCityZoneData)
CODE_CONVERT(_stOssZoneInfo)
CODE_CONVERT(_iTimeOffSet)
CODE_CONVERT(_iNeedCalcFruitTime)
CODE_CONVERT(_stAuctionZoneData)
CODE_CONVERT(_iNeedCalcFruitTime)
CODE_CONVERT(_iClearTreeRankTime)
CODE_CONVERT(_astGoldCardAct)
CODE_CONVERT(_iZoneCombineTime)
CODE_CONVERT(_iZoneRecorderCount)
CODE_CONVERT(_chStopOpenRegist)
CODE_CONVERT(_chStopCreateClan)
CODE_CONVERT(_stAcaCupZoneData)
CODE_CONVERT(_ucHasSendGanEnBigGift)
CODE_CONVERT(_aui64GanEnRecorder)
CODE_CONVERT(_stManorBattle)
CODE_CONVERT(_stRewardBack)
CODE_CONVERT(_aui64ZPRecorder)
CODE_CONVERT(_ucSDGetBigBonus)
CODE_CONVERT(_astSDRecord)
CODE_CONVERT(_astSDCharge)
CODE_CONVERT(_iGanEnLastOpenTime)
CODE_CONVERT(_astRockRecord)
END_CODE_CONVERT(CZoneData)

//////////////////////////////////////////////////////////////////////////
class CInstanceZoneDetailInfo : public CTCodeObject
{
public:
    CInstanceZoneDetailInfo()
    {
        Clear();
    }

    void Clear()
    {
        _ucInstanceType = 0;
        _usInstanceID = 0;
        _astNewKillEnemyVideos.Clear();
        _ucBestKillScore = 0;
    }

    void InitByKey(int iID)
    {
        _ucInstanceType = iID / 10000;
        _usInstanceID = iID % 10000;
    }

    static int GetKey(const unsigned char ucInstanceType, const unsigned short usInstanceID)
    {
        return ucInstanceType * 10000 + usInstanceID;
    }

    int GetKey() const
    {
        return GetKey(_ucInstanceType, _usInstanceID);
    }

    void SaveNewKillEnemyVideo(unsigned char ucMonsterPos, CTLib::CTSizeString<MAX_VIDEO_KEY_LEN>& szVideoToken)
    {
        if (ucMonsterPos <= 0 || ucMonsterPos > MAX_MONSTER_GROUP_PER_INSTANCE)
        {
            CT_ERROR(("%d", ucMonsterPos));
            return ;
        }

        while(ucMonsterPos > _astNewKillEnemyVideos.Size())
        {
            CTSizeString<MAX_VIDEO_KEY_LEN> szTmp;
            _astNewKillEnemyVideos.AddOneItem(szTmp);
        }
        _astNewKillEnemyVideos[ucMonsterPos - 1] = szVideoToken;
    }

    void GetNewKillEnemyVideo(unsigned char ucMonsterPos, CTLib::CTSizeString<MAX_VIDEO_KEY_LEN>& szVideoToken)
    {
        if (ucMonsterPos <= 0 || ucMonsterPos > MAX_MONSTER_GROUP_PER_INSTANCE)
        {
            CT_ERROR(("%d", ucMonsterPos));
            return ;
        }

        if (_astNewKillEnemyVideos.Size() < ucMonsterPos)
        {
            szVideoToken.Set("");
        }
        else
        {
            szVideoToken = _astNewKillEnemyVideos[ucMonsterPos - 1];
        }
    }

public:
    unsigned char _ucInstanceType;
    unsigned short _usInstanceID;

    CTLib::CTArray<CTLib::CTSizeString<MAX_VIDEO_KEY_LEN>, MAX_MONSTER_GROUP_PER_INSTANCE> _astNewKillEnemyVideos;  //最近击杀怪物录像ID, index位怪物位置，从0开始
    CTLib::CTSizeString<ROLENAME_LEN> _szFirstKillRoleName; //首杀用户昵称

    CTLib::CTSizeString<ROLENAME_LEN> _szBestKillRoleName;  //最优秀击杀
    unsigned char _ucBestKillScore;                         //最优秀击杀的分数
};

BEGIN_CODE_CONVERT(CInstanceZoneDetailInfo)
CODE_CONVERT(_ucInstanceType)
CODE_CONVERT(_usInstanceID)
CODE_CONVERT(_astNewKillEnemyVideos)
CODE_CONVERT(_szFirstKillRoleName)
CODE_CONVERT(_szBestKillRoleName)
CODE_CONVERT(_ucBestKillScore)
END_CODE_CONVERT(CInstanceZoneDetailInfo)

//用于给腾讯平台返回结果用，比如发货结果
class CTencentCallBack : public CTCodeObject
{
public:
    int ret;
    CTSizeString<1024> msg;
};
BEGIN_CODE_CONVERT(CTencentCallBack)
CODE_CONVERT(ret)
CODE_CONVERT(msg)
END_CODE_CONVERT(CTencentCallBack)

#endif //__COMMH_CLASS_H__


